Say I sample a discrete uniform distribution $U$ (say $U$ has a support of $N$ elements, and there is a total order on the elements) a number $K$ times, resulting in a random sequence $A_{i}$. What can I say about the probability that $A_{i}$ follows an alternating "up-down-up-down" pattern (or "down-up-down-up"), i.e. $A_{i} \ge A_{i+1} \mbox{ iff. } A_{i+1} \le A_{i+2}$ for all $i$?
Or, if there is a way to compute it exactly in my case $N = 20$ and $K = 18$. And, in my case $support(U) = {1,2,3,...N}$.
EDIT: Good approximations are OK.
A simpler dynamic programming approach is to keep a single vector of counts of zig-zag sequences that ended at a certain value in, say, a down movement, and invert it in each update. Then with $a_{ki}$ denoting the number of zig-zag sequences of length $k$ ending in $i$ on a down movement, we have
$$ a_{k+1,N+1-i}=\sum_{j=1}^ia_{kj} $$
(or with upper limit $i-1$ for strict inequality). Thus the update is described by a matrix of the form
$$ \pmatrix{ 1&1&1&1&1&1\\ 1&1&1&1&1&0\\ 1&1&1&1&0&0\\ 1&1&1&0&0&0\\ 1&1&0&0&0&0\\ 1&0&0&0&0&0 } $$
(or with zeros on the antidiagonal for strict inequality). We need to multiply by this matrix $K-1$ times, starting with initial values $a_{1i}=1$, then add all entries of the resulting vector and multiply by $2$ to also count zig-zag sequences ending in an up movement.
This is easily computed; the result, for $K=18$ and $N=20$, is $308129261694893525406$ for weak inequalities and $125294419211622187098$ for strict inequalities. (Here's the code.)
Thus the probability of obtaining a zig-zag sequence is
$$ \frac{308129261694893525406}{20^{18}}=\frac{154064630847446762703}{131072000000000000000000}\approx1.18\cdot10^{-3} $$
for weak inequalities and
$$ \frac{125294419211622187098}{20^{18}}=\frac{62647209605811093549}{131072000000000000000000}\approx4.78\cdot10^{-4} $$
for strict inequalities.
For $N\to\infty$, we can replace the discrete distribution by a continuous one. Then we're simply counting the alternating permutations of $K$ elements. This is OEIS sequence A001250 (the entry contains a lot of information about generating functions and the like), and the count for $K=18$ is $4809759350882$. Thus in this case the probability of obtaining a zig-zag sequence is
$$ \frac{4809759350882}{18!}=\frac{2404879675441}{3201186852864000}\approx7.51\cdot10^{-4}\;, $$
which is approximately the geometric mean of the other two probabilities. For finite $N$, this corresponds roughly to having $\frac12$ on the antidiagonal, i.e. letting each equality count as a satisfied inequality with probability $\frac12$. This yields a probability of obtaining a zig-zag sequence of
$$ \frac{25601115678617843777394720}{20^{18}\cdot2^{17}}=\frac{160006972991361523608717}{214748364800000000000000000}\approx7.45\cdot10^{-4}\;. $$