I will explain question by example. I throw coin 100 times. What is the probability I get one or more series of 8 or more heads in a row? Which theorem should I use? Is there a equation for this kind of experiments? I tried looking towards to Bernoulli distribution but still no clue.

There are similar questions for little different problems:

Expected number of coin tosses to get N consecutive, given M consecutive

Consecutive Coin Toss with static tosses

This one is really close: 3 heads in a sequence when a fair coin is tossed 5 times but does not give theoretical explanation I am looking for.

| cite | improve this question | | | | |
  • $\begingroup$ See geometric distribution. It returns probability that the event will appear the first time at that trial number. $\endgroup$ – ttnphns Mar 24 '13 at 11:28
  • $\begingroup$ Geometric distribution if about the number of Bernoulli trials needed to get one success. The problem of my statement is getting one or more. $\endgroup$ – Peter Demin Mar 24 '13 at 12:02
  • $\begingroup$ Let p be the prob of event. cdf.geom(3,p) is the probability that the event will first occur either in 1st or in 2nd or in 3rd trial. Hence 1-cdf.geom(3,p) is the probability that the event will still not occure after the 3 trials. Let the "event" be the failure (tail, not head). Here you are. $\endgroup$ – ttnphns Mar 24 '13 at 12:49

Consider the problem as a Markov chain with states for: 0, 1, ..., 7 heads at the end of the string, and a state for 8 heads seen in a row. Design the transition matrix such that seeing a tail with probability half sends you back to state 0, and otherwise with probability half advances you to the next state (the final state is an absorbing state). Raise this matrix to the $n$th power. The value in the first row, and last column is the probability of seeing 8 heads in a row. In Python:

import numpy as np

a = np.zeros((9, 9))
for i in range(8):
    a[i, 0] = a[i, i + 1] = 0.5
a[8, 8] = 1.0

print(np.linalg.matrix_power(a, 100)[0, 8])

gives 0.170207962419. Using the Fraction type gives an exact answer of 6742632053880245534447059849/39614081257132168796771975168.

| cite | improve this answer | | | | |

This can be answered using recursion/dynamic programming. The method is given in detail in the answer to this question: Probability over multiple blocks of events . Using this method in a spreadsheet, I found the probability of achieving 8 consecutive heads in 100 tosses to be 0.170207962419

| cite | improve this answer | | | | |

According to results in my research project:


Probability of having a series of length 1 is 1/4. For 2 - 1/8, for 3 - 1/16 ans so on. So the general equation for meeting a sequence of k equal results is

p(k) = 1/2^(k+1)

and having a sequence with length of 8 or more is:

sum(1/2^9 + 1/2^10 + 1/2^11 + ...) ~= 1/2^8

The probability for sequence of length 1 confuses me a little, because, intuitially it must be 1/2, so maybe all numbers must be multiplied by 2 having general equation

p(k) = 1/2^k

| cite | improve this answer | | | | |
  • $\begingroup$ Your last formula p(k)=prob^k [where prob is the prob of win in a single trial] gives correct result and is exactly the same as my earlier suggestion: p(k)=1-cdf.geom(k,1-prob). In fact, we know that basics that with k independent trials the joint probability to win in all the trials is prob^k. $\endgroup$ – ttnphns Mar 25 '13 at 6:23
  • 2
    $\begingroup$ But I don't think the geometric will give you the answer. For 8 tosses, the probability is 1/256. For 9 tosses, there are 3 combinations that work: all heads, a tail then 8 heads, or 8 heads and then a tail, for a probability of 3/512. How do you get the answer for 9 tosses using a geometric? $\endgroup$ – soakley May 2 '13 at 2:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.