A level () is an occurrence of two consecutive equal entries in a word , while a rise () or descent () occurs when the right or left entry, respectively, is strictly larger. If and are -ary words of the same given length and , then there is, for example, an occurrence of at index if and , and likewise for the other possibilities. Similar terminology may be used when discussing ordered -tuples of -ary words of length (the set of which we’ll often denote by ).
In this paper, we consider the problem of enumerating the members of according to the number of occurrences of the pattern , where and is any word of length in the alphabet . In particular, we find an explicit formula for the generating function counting the members of according to the number of occurrences of the patterns , , which, by symmetry, is seen to solve the aforementioned problem in its entirety. We also provide simple formulas for the average number of occurrences of within all the members of , providing both algebraic and combinatorial proofs. Finally, in the case , we solve the problem above where we also allow for \textit{weak rises} (which we’ll denote by ), i.e., indices such that in . Enumerating the cases and seems to be more difficult, and to do so, we combine the kernel method with the simultaneous use of several recurrences.