1

I want to calculate the probability of getting heads at least $5$ times in a row from $30$ throws.

Probability of getting a head is $1/2$. Now, probability of getting 2 heads in a row is $1/4$, etc. My idea was to do it like a normal probability etc. N = $2^{30}$ and $n=30, r=5$

$nCr = 142506$

$\frac{n}{N} = 0.0001327$

The problem is, that this is the answer for exactly $5$ heads from $30$ throws, no? Is there a better way than to calculate it one by one?

N. F. Taussig
  • 76,571
  • 1
    The usual approach when you're looking for "at least" is to consider the complement. Compute the probability of getting at most 4 heads in a row. – Ted Shifrin Mar 17 '22 at 21:53
  • This has been asked tons of times here. See eg https://math.stackexchange.com/questions/59738/probability-for-the-length-of-the-longest-run-in-n-bernoulli-trials https://math.stackexchange.com/questions/2480924/if-i-flip-a-biased-coin-n-times-what-is-the-probability-that-i-get-a-streak-o https://math.stackexchange.com/questions/417762/probability-of-20-consecutive-success-in-100-runs ... – leonbloy Mar 18 '22 at 17:49

2 Answers2

1

I give here a possible approach. Probably, it is not the fastest in your case, but it is an example of a quite powerful method (transfer matrix approach) that has many applications (for instance in statistical physics).

Let us denote as $P_N$ probability of finding at least $5$ consecutive successes in $N$ trials. Let us assume that the probability of a success is $\gamma$.

If $N=5$, clearly you have that $P_5 = \gamma^5$. Now, what happen if $N=6$? Well, we have to consider the probability of having $5$ successes in the first $5$ trials. Then you have the case in which the first attempt was a failure, and the next $5$ were successful. Equivalently, this mean that the last $4$ attempts of the first $5$ trials were successful (although the first attempt wasn't), and than the $6$-th trial was successful as well.

Now, I will denote as $+$ a success and as $-$ a failure. I will call $Q_5^4$ the probability of having the following $5$ trials: $-++++$. From the previous discussion we have that $$P_6 = P_5 + \gamma Q^4_5\,.$$

Now, let us generalise this notation. We call $Q_N^n$ (with $N\geq 5$ and $n\in\{0, 1,2,3,4\}$) the probability that, given $N$ attempts, there is no $5$ consecutive successful trials, the last $n$ trials were successful, and the $(n+1)$-th last attempt failed. For instance, $Q^3_7$ will be the probability of having one event in the form $\dots -+++$, composed of $7$ total trials and without $5$ successes in a row.

It is not hard to see that $$Q^4_6=Q^3_5\gamma\,,$$ $$Q^3_6=Q^2_5\gamma\,,$$ $$Q^2_6=Q_1^5\gamma\,,$$ $$Q^1_6 = Q^0_5\gamma\,,$$ and $$Q^0_6 = (1-P_5)(1-\gamma) = (Q^4_5+Q^3_5+Q^2_5+Q^1_5+Q^0_5)(1-\gamma)\,.$$

Now, let us define the vector $$R_N = \begin{pmatrix}P_N\\Q_N^4\\ Q_N^3\\ Q_N^2\\ Q_N^1\\ Q_N^0\end{pmatrix}\,.$$

Now, it is not hard to check that $R_6 = \Gamma R_5$, where $$\Gamma = \begin{pmatrix} 1 & \gamma & 0 & 0 & 0 & 0 \\ 0 & 0 & \gamma & 0 & 0 & 0 \\ 0 & 0 & 0 & \gamma & 0 & 0 \\ 0 & 0 & 0 & 0 & \gamma & 0 \\ 0 & 0 & 0 & 0 & 0 & \gamma \\ 0 & 1-\gamma & 1-\gamma & 1-\gamma & 1-\gamma & 1-\gamma \end{pmatrix}\,.$$

Actually, it is not hard to see that this is true for all $N\geq 5$, in the sense that $$R_{N+1} = \Gamma R_N\,.$$

Now, you can compute exactly $R_5$ and you get $$R_5 = \begin{pmatrix} \gamma^5\\(1-\gamma)\gamma^4\\(1-\gamma)\gamma^3\\(1-\gamma)\gamma^2\\(1-\gamma)\gamma\\1-\gamma\end{pmatrix}\,.$$

You are actually interested in $P_{30}$ with $\gamma=1/2$. This can be obtained by computing $R_{30}$. You have $$R_{30} = \Gamma^{25} R_5\,.$$

I evaluated this expression with Mathematica and I got $$R_{30}\simeq \begin{pmatrix}0.3682\\ 0.0215\\ 0.0423\\0.0831\\0.1635\\0.3214\end{pmatrix}$$ that means that $P_{30}\simeq .3682$.

Note that this method can be easily generalised to different values of successes in a row, as you will always have matrices $\Gamma$ with a very similar structure, just of different size.

ECL
  • 2,960
0

The answer involves using the 5-step Fibonacci sequence (nickname Pentanacci - http://oeis.org/A001591). Each of the prior 5 numbers tracks how many throw sequences have 0, 1, 2, 3, 4 heads in a row and the sum tracks the cumulative throws that didn't generate 5 in a row. The complement of that yields the answer.

see the following discussing 2 and 3 heads in a row. https://wizardofvegas.com/forum/questions-and-answers/math/14915-fibonacci-numbers-and-probability-of-n-consecutive-losses/

Let me know if you just need this hint as an approach or if you need further detail.