This question talks about expected number of runs in a series of coin flips. I have a related problem where i need to calculate the CONDITIONAL expectation of runs in a series of $n$ flips, given $n_1$ of them are heads, and $n_2$ are tails such that $n_1 + n_2 = n$. I represent this conditional expectation by $E(n_1, n_2)$
Using similar logic as above question, I tried this:
Given $n_1$, $n_2$ and $E(n_1, n_2)$, $E(n_1 + 1, n_2)$ should increment by $1$ if last toss was tails (prob${}=\frac{n_2}{n_1 + n_2}$
$$E(n_1 + 1, n_2) = E(n_1, n_2) + \frac {n_2}{n_1+n_2} $$
Similarly
$$E(n_1, n_2 + 1) = E(n_1, n_2) + \frac {n_1}{n_1+n_2} $$
Starting with $E(n_1, 0) = E(0, n_2) = 1$, I get
$$E(n_1, n_2) = 1 + \sum_k (\frac{n_1}{n_1+k} ) = 1 + \sum_k (\frac{n_2}{n_2+k} ) $$
But this doesn't look right. Is there a better way to approach this?
The important part here is to understand that given $n_1,n_2$, the probability that two consecutive tosses are different is no longer depends on $p$, but rather equals to $2\tfrac{n_1 n_2}{n(n-1)}$. The reason is that the number of $H$ and $T$ is fixed so it is only a question of how they are arranged in a row. The probability of $H$ on a particular throw is $\tfrac{n_1}{n}$ and the probability of tails on the next throw is $\tfrac{n_2}{n-1}$.
The rest of the solution should be identical to the linked question, so the answer should be $$1+2\tfrac{n_1 n_2}{n_1+n_2}$$