Expected number of runs when there are $n_1$ objects of one kind and $n_2$ objects of second kind. Flaw in Argument? Suppose there are $n_1$ objects of one kind and $n_2$ objects of the second kind. These objects appear randomly in a sequence. I want to find the expected number of runs in the sequence.
Attempt: Define the variable $Y_i$ as
\begin{cases} 
      1 & i\text{th elements is different from } (i-1)th \\
      0 & \text{Otherwise} \\
   \end{cases}
The number of runs $R = 1 + \sum_{2}^n Y_i$
$\implies \mathbb E[R] = 1 + \sum_2^n P(Y_i) \text{where } n = n_1 + n_2$
To calculate $P(Y_i) : $ the following argument :
$i$th position can be occupied by either Type-$1$ object in which case, the $i-1$th object must be occupied by type $2$ object. This happens in $n_1 \times n_2$ ways
Similarly when $i$th position is occupied by Type-$2$ object, the $(i-1)$th object must be occupied by type $1$ object which also happens in $n_1 \times n_2 $ ways
Summing up the required probability is $\dfrac{2 \times n_1 n_2}{^nC_2}$ and hence $\mathbb E[R] = 1 + \sum_2^n \dfrac{2 \times n_1 n_2}{^nC_2}$.

But the book which I am reading seems to exclude $2$ from the
numerator and states required probability as $\dfrac{n_1 n_2}{^nC_2}$.

Could this be a typo? Thanks!
 A: The probability that the two elements are different can be calculated either taking into account their ordering or not.
If we don't take into account the ordering, the total cases are $\binom{n_1+n_2}{2}$ and the favorable cases are $n_1 n_2 $. The probability $P(Y_i=1)$ is then
$$ \frac{n_1 n_2}{\binom{n_1+n_2}{2}}$$
If we count the ordering, the total cases are $ 2 \binom{n_1+n_2}{2} = (n_1 + n_2)(n_1 + n_2 -1)$ (variation, instead of combination) and the favorable cases are $2 n_1 n_2 $. The ratio, of course, is the same.
You erred in mixing both approaches.
BTW: when in doubt, do some elementary sanity check. In this case, you can test $n_1=n_2=1$.
A: The probability is $$1+\frac{2n_1n_1}{n_1+n_2}$$. Take e.g. $$n_1=n_2=1$$, then the sequences are ab (run length 2) and ba (run length 2) with sum of run lenghts equal to 4 and $\binom{n_1+n_2}{n_1}=2$ sequences, giving an expectation value of 4/2=2.
For $n_1=n_2=2$ the sequences are aabb (2 runs), abab (4 runs), abba (3 runs), baab (3 runs), baba (4 runs), bbaa (2 runs), so 2+4+3+3+4+2=18. The expectation value of the 6 sequences is 18/6=3.
For $n_1=1$, $n_2=2$ the sequences are aab (2 runs), aba (3 runs), baa (2 runs), so 2+3+2=7 and the expectation value is 7/3.
A more detailed evaluation is in https://oeis.org/A349147 .
A: The binomial coefficient in the denominator threw you off.
$$\frac{n_1n_2}{\binom n2}=\frac{\binom{n_1}{1}\binom{n_2}{1}}{\binom{n}2}=2\frac{n_1n_2}{n(n-1)}.$$
This is indeed a hypergeometric type probability. So, to get an end of a run at position $i$ does not actually depend on the position  and has the same probability as to just choose two objects of different kind from the $n$ given.
Equally ,
$$\mathbf P(Y_i=0)=\frac{\binom{n_1}{0}\binom{n_2}{2}}{\binom{n}2}+\frac{\binom{n_1}{2}\binom{n_2}{0}}{\binom{n}2}$$
The hypergeometric distribution has some curious properties...
Hope that helped ;)
