0
$\begingroup$

In the runs above and below the mean test of independence, the mean is

MEAN = (2*n1*n2)/N - (1/2)

So here, are n1 and n2 runs above and below or instances of numbers above and below?

In other words, is

n1 + n2 = N

or,

n1 + n2 = b (where b is equal to total number of runs)

  • 0
    [This site](http://www.eg.bucknell.edu/~xmeng/Course/CS6337/Note/master/node44.html) may have what you're looking for.2011-11-25

1 Answers 1

2

I wouldn't have been able to make any sense of the question without this page. It would have been a lot clearer if you'd mentioned that you mean two different things by "the mean", where "MEAN" in the first formula means not the mean of the distribution itself but the mean number of runs, conditional on $n_1$ and $n_2$. Also you failed to introduce $N$ as the total number of observations and gave the formulas for the two possibilities in reverse order from the order in the text.

As the linked page states, $n_1$ and $n_2$ are numbers of individual observations. You can derive the mean number of runs using linearity of expectation. For $N$ observations, there are $N-1$ adjacent pairs of observations. Given $n_1$ and $n_2$, for each pair the probability of not continuing a run is

$\frac{\binom{n_1}2}{\binom N2}+\frac{\binom{n_2}2}{\binom N2}=\frac{n_1^2-n_1+n_2^2-n_2}{N^2-N}\;.$

The probability of breaking a run is $1$ minus this, by linearity of expectation the expected number of breaks between runs is just $N-1$ times that, and the expected number of breaks is $1$ more than this, so we have

$ \begin{eqnarray} \mu_b &=& (N-1)\left(1-\frac{n_1^2-n_1+n_2^2-n_2}{N^2-N}\right)+1 \\ &=& (N-1)\left(1-\frac{n_1^2-n_1+n_2^2-(N-n_1)}{N^2-N}\right)+1 \\ &=& (N-1)\left(1-\frac{n_1^2+n_2^2-N}{N^2-N}\right)+1 \\ &=& (N-1)\frac{N^2-(n_1^2+n_2^2)}{N^2-N}+1 \\ &=& \frac{(n_1+n_2)^2-(n_1^2+n_2^2)}N+1 \\ &=& \frac{2n_1n_2}N+1\;. \end{eqnarray} $

It's strange that you have $-\frac12$, the linked page has $\frac12$ and I have $1$, but you can check for $N=1$ and $N=2$ that $1$ is correct.