Ballot theorem (source code)

= Ballot theorem

Among words with $a$ up-steps and $b$ down-steps, $a>b$, the number whose running balance is strictly positive after every step is $\frac{a-b}{a+b}\binom{a+b}{b}$. For nonnegative running balance with $a\ge b$, the count is the <ballot number> $\binom{a+b}{b}-\binom{a+b}{b-1}$. These are different boundary conventions; the nonnegative formula follows by reflecting the prefix through the first step below zero.