Binomial distributions for cumulative tossing coins probabilities using monte carlo.

clarcombe

New member
Joined
Jan 13, 2015
Messages
1
I have the following conundrum

I want to toss a coin up to 5 times until I get a head.

If I get a tail, I retoss the coin if coin toss is less than 5 times.

So I could get the following

1 head
1 tail 1 head
2 tails in a row then 1 head
3 tails in a row then 1 head
4 tails in a row then 1 head
5 tails


I thought I could use binomial distribution function to calculate the odds for each but the formula doesnt take into account the specific order. I can work it out on a piece of paper e.g.TH, TTH etc finding all my relevant combinations, but there must be a neater way.

I then wanted to run this simulation multiple times to get a 95% confidence rate. How would I achieve this ?

Thanks in advance
 
I have the following conundrum

I want to toss a coin up to 5 times until I get a head.

If I get a tail, I retoss the coin if coin toss is less than 5 times.

So I could get the following

1 head
1 tail 1 head
2 tails in a row then 1 head
3 tails in a row then 1 head
4 tails in a row then 1 head
5 tails


I thought I could use binomial distribution function to calculate the odds for each but the formula doesnt take into account the specific order. I can work it out on a piece of paper e.g.TH, TTH etc finding all my relevant combinations, but there must be a neater way.

I then wanted to run this simulation multiple times to get a 95% confidence rate. How would I achieve this ?

Thanks in advance
Since trials (the flip of the coin) are assumed independent, the probability of a sequence of events is just the product of the probability of the events. What could be confusing in a situation such as this [two equal possibilities] is that the probability of getting 4 tails in a row and then a heads is the same as getting 4 heads in a row and then a tails which is the same as getting 5 tails (or 5 heads) in a row. So, assuming a fair coin and letting P(string) be the probability of getting that string of events, i.e. P(HT) is probability of getting a heads and then a tails,
P(H) = 1/2
P(HH) = P(HT) = P(TH) = P(TT) = 1/4
....

EDIT: BTW: The above result can be obtained directly from the binomial distribution. The probability of getting exactly k successes in n trials is given by
f(k,n,p) = \(\displaystyle \begin{pmatrix}n\\k\end{pmatrix}\, p^k\, (1-p)^{n-k}\),
see
https://en.wikipedia.org/wiki/Binomial_distribution
for example. For our case p=1-p=1/2 so
f(k,n,p) = \(\displaystyle \begin{pmatrix}n\\k\end{pmatrix}\, (\frac{1}{2})^n\).
But, as you mentioned, that is for no particular order. To reduce it to a particular order we need to divide by the number of ways one can order the particular sequences. That is just \(\displaystyle \bigl( \begin{smallmatrix}n\\k\end{smallmatrix}\bigr)\). Dividing the last equation by that, we get the result
P(string,n) = \(\displaystyle (\frac{1}{2})^n\)
 
Last edited:
I want to toss a coin up to 5 times until I get a head.
If I get a tail, I retoss the coin if coin toss is less than 5 times.
So I could get the following
1 head
1 tail 1 head
2 tails in a row then 1 head
3 tails in a row then 1 head
4 tails in a row then 1 head
5 tails
I suggest that we simply count them.
Take a piece of lined paper and create a table of thirty-two rows & five columns. Now fill it out.

In the first column place sixteen H's followed by sixteen T's. That column is filled. (two blocks)
In the second column place eight H's followed by eight T's and repeat until that column is filled. (four blocks)
In the third column place four H's followed by four T's and repeat until that column is filled. (eight blocks)
In the fourth column place two H's followed by two T's and repeat until that column is filled. (sixteen blocks)
In the finial column place an H followed by a T alternating until the last column is filled.

Now we have modeled your question: that table is all possible outcomes of tossing a coin five times.
Sixteen rows begin with an H.
Eight rows begin with a TH.
Four rows begin with a TTH.
Two rows begin with a TTTH.
One row begin with a TTTTH.
One row is TTTTT.

Now, that may seem to be a heck of a lot of work. But years and years of teaching this tells me that it works in leading to a understanding.
 
Top