NIST states that the average and variance of a number of runs in the "runs above and below median" test as $$ \overline{R} = \frac{2n_a n_b}{n_a + n_b} + 1 \\ s^2 = \frac{2n_a n_b(2n_a n_b - n_a - n_b)}{(n_a+n_b)^2 (n_a+n_b-1)} $$ where $n_a$ is the number of values above the median and $n_b$ is the number of values below the median.
How is this result proved? Actually, more importantly, how do I begin to think about this problem?
It seems to me that this result might actually be valid more generally for "runs above/below threshold", since most likely $n_a = n_b$ for runs above median.