[Math] probability of flipping a total of 20 heads before flipping 10 tails in a row

probability

I want to find the probability that I will flip a fair coin and get $10$ heads in a row before I flip a total of $20$ tails. Or the opposite, the probability that I will flip a total of $20$ heads before I flip $10$ tails in a row. I would like to see the work and have an explanation. Also, this should be able to be applied to an unfair coin. Thanks!

The probability of flipping $10$ heads or tails in a row would be $(0.5)^{10}$ for a fair coin. I know how to figure out the probability of a total of $20$ tails in $x$ flips, but $x$ has to be defined to get an answer, at least as far as I am aware.

Thanks!

Best Answer

For every $n\geqslant0$, let $p_n$ denote the probability that $n$ tails appear before any run of $10$ heads is completed. Then $p_0=1$ and, for every $n\geqslant0$, conditioning on the time when the $n$th tail appears, one gets $p_{n+1}=p_n\cdot(1-q)$, where $q$ is the probability that $10$ heads appear before the first next tail. Thus, $q=h^{10}$ and $p_n=(1-h^{10})^n$, where $h$ is the probability to get a head, here $h=\frac12$.

The probability to get $10$ heads in a row before flipping a total of $20$ tails is $$ 1-(1-2^{-10})^{20}\approx20\cdot2^{-10}\approx2\%. $$ Refining only slightly this, one sees that the length of the longest run of heads before flipping a total of $n$ tails is of the order of $\log_2n$ when $n\to\infty$.