# Consecutive Heads/Tails in weighted coin toss

• Sep 3rd 2008, 03:44 PM
slyone
Consecutive Heads/Tails in weighted coin toss
Hi,

Supposing you have a weighted coin which lands heads up 70% of the time and tails up 30% of the time.

Q. What is the probability that it lands on tails 20 or more times in a row if I did this 1000 times?

*Also could I have the equation on how you worked this out so that I can change the weighting, number of trials etc (I need to know this for my business!!!)

Thank you very much.

Zak
• Sep 10th 2008, 05:11 PM
awkward
Quote:

Originally Posted by slyone
Hi,

Supposing you have a weighted coin which lands heads up 70% of the time and tails up 30% of the time.

Q. What is the probability that it lands on tails 20 or more times in a row if I did this 1000 times?

*Also could I have the equation on how you worked this out so that I can change the weighting, number of trials etc (I need to know this for my business!!!)

Thank you very much.

Zak

Hi Zak,

I don't know how to compute the probability you seek exactly, but I think I can give a pretty good approximation.

To generalize the problem, let's suppose you have a possibly biased coin which comes up tails with probability p and heads with probability q, where p+q = 1. You flip the coin N times and look for a run of R or more successive tails. We would like to know the probability that at least one such run occurs. The "at least one" part is my interpretation of your problem statement; you didn't say that, but I'm guessing that's what you mean.

As I said, I haven't come up with a reasonable way to compute the exact probability of having at least one run of length R, but think I can solve a closely associated problem which can be used to obtain an approximate answer.

Let $\displaystyle \lambda$ be the expected number of runs of R or more successive tails. It can be shown that

$\displaystyle \lambda = p^R \,[(N - R) q + 1]$.

That is an exact result, not an approximation. (I derived this formula from scratch, but I suppose it must be a well-known result.) So in your case, for example, we have N = 1000, R = 20, p = 0.3 and q = 0.7, so $\displaystyle \lambda = 2.4 * 10^{-8}$.

Now comes the approximation. Let's suppose the number of runs, say X, has a Poisson distribution with mean $\displaystyle \lambda$. It doesn't, but for small values of $\displaystyle \lambda$ it should be pretty close. Then

$\displaystyle Pr(X > 0) = 1 - Pr(X = 0) = 1 - e^{-\lambda}$.

For small values of $\displaystyle \lambda$ this value can be hard to compute precisely, but we can use another approximation:

$\displaystyle 1 - e^{-\lambda} = \lambda$ (approximately),

so the answer to your question is (once again, approximately) $\displaystyle \lambda = 2.4 * 10^{-8}$.
• Apr 13th 2013, 02:05 AM
ottof
Re: Consecutive Heads/Tails in weighted coin toss
Hi, great answer from awkward. But how did you figure out the expected number of runs of R or more successive tails:
\lambda = p^R \,[(N - R) q + 1].
You derived this formula from scratch. I tried to figure by myself this result and tried to Google it and did not find an answer.
Could you share your Derivation ?
Thanks
Otto
• Apr 13th 2013, 03:04 AM
Shakarri
Re: Consecutive Heads/Tails in weighted coin toss
The chance of getting 20 tails in a row in 20 tosses is 0.320. When tossing a coin 1000 times there is are (1000-20+1)=981 times where you can have 20 of an outcome in a row. Since it is 20 or more we don't care what the other 980 tosses are.
Since the chance of getting 20 in a row in one attempt is 0.320 and you get 981 attempts the chance of getting 20 in a row through the whole 1000 tosses is 981(0.320)
• Apr 14th 2013, 05:52 AM
awkward
Re: Consecutive Heads/Tails in weighted coin toss
Quote:

Originally Posted by ottof
Hi, great answer from awkward. But how did you figure out the expected number of runs of R or more successive tails:
$\displaystyle \lambda = p^R \,[(N - R) q + 1]$
You derived this formula from scratch. I tried to figure by myself this result and tried to Google it and did not find an answer.
Could you share your Derivation ?
Thanks
Otto

Let
$\displaystyle X_i = \begin{cases} 1 &\text{if there is a run of at least R tails starting with flip i}\\0 &\text{otherwise} \end{cases}$
Then $\displaystyle X_1 = 1$ if the first R flips are tails,
but for $\displaystyle i > 1$, $\displaystyle X_i = 1$ if the (i-1)st flip is a head and the next R flips are tails.

So
$\displaystyle E(X_1)=\Pr(X_1 = 1) = p^R$
and
$\displaystyle E(X_i)=\Pr(X_i = 1) = q p^R$ for $\displaystyle i > 1$

Applying the theorem that E(X+Y) = E(X) + E(Y), we have

$\displaystyle E \left( \sum_{i=0}^{N-R+1} X_i \right) = \sum_{i=0}^{N-R+1} E(X_i) = p^R + (N-R)q p^R = p^R [(N-R)q + 1]$
The content structure of the text passage involves a user asking a probability question about a weighted coin and a detailed response from another user providing a solution, including a formula and an explanation.
single_question_with_answer
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
# Consecutive Heads/Tails in weighted coin toss

• Sep 3rd 2008, 03:44 PM
slyone
Consecutive Heads/Tails in weighted coin toss
Hi,

Supposing you have a weighted coin which lands heads up 70% of the time and tails up 30% of the time.

Q. What is the probability that it lands on tails 20 or more times in a row if I did this 1000 times?

*Also could I have the equation on how you worked this out so that I can change the weighting, number of trials etc (I need to know this for my business!!!)

Thank you very much.

Zak
• Sep 10th 2008, 05:11 PM
awkward
Quote:

Originally Posted by slyone
Hi,

Supposing you have a weighted coin which lands heads up 70% of the time and tails up 30% of the time.

Q. What is the probability that it lands on tails 20 or more times in a row if I did this 1000 times?

*Also could I have the equation on how you worked this out so that I can change the weighting, number of trials etc (I need to know this for my business!!!)

Thank you very much.

Zak

Hi Zak,

I don't know how to compute the probability you seek exactly, but I think I can give a pretty good approximation.

To generalize the problem, let's suppose you have a possibly biased coin which comes up tails with probability p and heads with probability q, where p+q = 1. You flip the coin N times and look for a run of R or more successive tails. We would like to know the probability that at least one such run occurs. The "at least one" part is my interpretation of your problem statement; you didn't say that, but I'm guessing that's what you mean.

As I said, I haven't come up with a reasonable way to compute the exact probability of having at least one run of length R, but think I can solve a closely associated problem which can be used to obtain an approximate answer.

Let $\displaystyle \lambda$ be the expected number of runs of R or more successive tails. It can be shown that

$\displaystyle \lambda = p^R \,[(N - R) q + 1]$.

That is an exact result, not an approximation. (I derived this formula from scratch, but I suppose it must be a well-known result.) So in your case, for example, we have N = 1000, R = 20, p = 0.3 and q = 0.7, so $\displaystyle \lambda = 2.4 * 10^{-8}$.

Now comes the approximation. Let's suppose the number of runs, say X, has a Poisson distribution with mean $\displaystyle \lambda$. It doesn't, but for small values of $\displaystyle \lambda$ it should be pretty close. Then

$\displaystyle Pr(X > 0) = 1 - Pr(X = 0) = 1 - e^{-\lambda}$.

For small values of $\displaystyle \lambda$ this value can be hard to compute precisely, but we can use another approximation:

$\displaystyle 1 - e^{-\lambda} = \lambda$ (approximately),

so the answer to your question is (once again, approximately) $\displaystyle \lambda = 2.4 * 10^{-8}$.
• Apr 13th 2013, 02:05 AM
ottof
Re: Consecutive Heads/Tails in weighted coin toss
Hi, great answer from awkward. But how did you figure out the expected number of runs of R or more successive tails:
\lambda = p^R \,[(N - R) q + 1].
You derived this formula from scratch. I tried to figure by myself this result and tried to Google it and did not find an answer.
Could you share your Derivation ?
Thanks
Otto
• Apr 13th 2013, 03:04 AM
Shakarri
Re: Consecutive Heads/Tails in weighted coin toss
The chance of getting 20 tails in a row in 20 tosses is 0.320. When tossing a coin 1000 times there is are (1000-20+1)=981 times where you can have 20 of an outcome in a row. Since it is 20 or more we don't care what the other 980 tosses are.
Since the chance of getting 20 in a row in one attempt is 0.320 and you get 981 attempts the chance of getting 20 in a row through the whole 1000 tosses is 981(0.320)
• Apr 14th 2013, 05:52 AM
awkward
Re: Consecutive Heads/Tails in weighted coin toss
Quote:

Originally Posted by ottof
Hi, great answer from awkward. But how did you figure out the expected number of runs of R or more successive tails:
$\displaystyle \lambda = p^R \,[(N - R) q + 1]$
You derived this formula from scratch. I tried to figure by myself this result and tried to Google it and did not find an answer.
Could you share your Derivation ?
Thanks
Otto

Let
$\displaystyle X_i = \begin{cases} 1 &\text{if there is a run of at least R tails starting with flip i}\\0 &\text{otherwise} \end{cases}$
Then $\displaystyle X_1 = 1$ if the first R flips are tails,
but for $\displaystyle i > 1$, $\displaystyle X_i = 1$ if the (i-1)st flip is a head and the next R flips are tails.

So
$\displaystyle E(X_1)=\Pr(X_1 = 1) = p^R$
and
$\displaystyle E(X_i)=\Pr(X_i = 1) = q p^R$ for $\displaystyle i > 1$

Applying the theorem that E(X+Y) = E(X) + E(Y), we have

$\displaystyle E \left( \sum_{i=0}^{N-R+1} X_i \right) = \sum_{i=0}^{N-R+1} E(X_i) = p^R + (N-R)q p^R = p^R [(N-R)q + 1]$
user
The content structure of the text passage involves a user asking a probability question about a weighted coin and a detailed response from another user providing a solution, including a formula and an explanation.

TYPE: SINGLE_QUESTION_WITH_ANSWER