CasinoCrasher
CasinoCrasher
  • Threads: 10
  • Posts: 41
Joined: Oct 4, 2015
February 25th, 2020 at 7:51:17 PM permalink
I am wanting to use a geometric series to determine the number of trials or flips it takes in a fair coin toss to get 2 heads. It is my understanding that a geometric series will give you the number of failures before a success. The failures in this case being the prior flips before you see the second heads. Could someone please show and explain how to write out and use a geometric series to solve this problem. Below I have the notation and general form of a geomtric series along with the general solution. Intuitivly I know the answer is 4 and you can get it from the basic sum of the inverse probabilites (1/p+1/p = 1/0.5 +1/0.5 = 4)but, you can see from my math below that this is not the answer that I get with the geometric series. I know a geomtric series is not required to answer this question, I just want to make sure I fully understand how to use a geometric series before applying it to a more complicated problem.

Using,

S(n)=a+ar+ar^2+ c +ar^n-1+ar^n

S(n)=a(1-r^n)/(1-r) ; if r1 ; if IrI<1

a=first term
n=number of terms
r=common ratio

When writing out the series using the form from above,

S(n)=2+0.5^(2-1)+0.5^(2)

The first term I am using is 2 because it takes at least 2 trails to get a success, then the second term is 0.5, the probability of getting heads in any one flip. I stopped at the third term since this would be n, which I believe should be the number of heads you want. Then from this equation I get,

a=2
n=2
r=0.25

Then using the general solution from my second equation above,

S(n)=2*(1-0.25^2)/(1-0.25)=2.5
Wizard
Administrator
Wizard
  • Threads: 1520
  • Posts: 27118
Joined: Oct 14, 2009
February 25th, 2020 at 8:21:08 PM permalink
If question is asking flips required to get two heads in a row.

I get an answer of 6. Without discussion geometric series, there are two states the player can be in:

1. Initial state or last flip was tails (in other words two heads needed).
2. Last flip was heads (in other words, one head needed).

Let x = expected flips needed from state (1).
Let y = expected flips needed from state (2).

x = 1 + x/2 + y/2. In other words, after a flip, the player will have a 50/50 chance of being in state 1 or 2.
y = 1 + x/2. In other words, after a flip from state x, the player will either have achieved two heads or be back to state x.

Substituting the second equation into the first:

x = 1 + x/2 + (1 + x/2)/2
2x = 2 + x + (1 + x/2)
2x = 3 + (3/2)x
4x = 6 + 3x
x = 6

If question is asking flips required to get a total of two heads.

It takes an average of two flips to get each heads. Thus 2*2=4 flips required to get two heads.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ssho88
ssho88
  • Threads: 58
  • Posts: 682
Joined: Oct 16, 2011
February 25th, 2020 at 9:23:58 PM permalink
F0 = Flips required after you get 0 heads
Fn = Flips required after you get n heads
probability of flipping heads = P = 0.5, probability of flipping tails = q = 0.5
Fn = p(1 + Fn+1) + q(1 + F0)

So,
F2 = 0
F1 = 0.5(1 + F2) + 0.5(1 + F0) - - - - Eq1
F0 = 0.5(1 + F1) + 0.5(1 + F0) - - - - Eq2

Substitute Eq1 to Eq2,
0.5 F0 = 1+ 0.5(0.5(1 + 0) + 0.5(1 + F0))
0.5 F0 = 1+ 0.5(1 + 0.5 F0)
0.25 F0 = 1.5
F0 = 6
Last edited by: ssho88 on Feb 25, 2020
CasinoCrasher
CasinoCrasher
  • Threads: 10
  • Posts: 41
Joined: Oct 4, 2015
February 28th, 2020 at 3:25:37 PM permalink
Quote: Wizard

If question is asking flips required to get two heads in a row.

I get an answer of 6. Without discussion geometric series, there are two states the player can be in:

1. Initial state or last flip was tails (in other words two heads needed).
2. Last flip was heads (in other words, one head needed).

Let x = expected flips needed from state (1).
Let y = expected flips needed from state (2).

x = 1 + x/2 + y/2. In other words, after a flip, the player will have a 50/50 chance of being in state 1 or 2.
y = 1 + x/2. In other words, after a flip from state x, the player will either have achieved two heads or be back to state x.

Substituting the second equation into the first:

x = 1 + x/2 + (1 + x/2)/2
2x = 2 + x + (1 + x/2)
2x = 3 + (3/2)x
4x = 6 + 3x
x = 6

If question is asking flips required to get a total of two heads.
ta
It takes an average of two flips to get each heads. Thus 2*2=4 flips required to get two heads.



Forgive me, I may have slightly misstated my intended problem statement here. I am trying to see the probability of getting "at least 2" two heads before a tails in a fair coin toss, consecutively or non-consecutively, either way (both cases apply)?
CasinoCrasher
CasinoCrasher
  • Threads: 10
  • Posts: 41
Joined: Oct 4, 2015
February 28th, 2020 at 3:27:00 PM permalink
Quote: Wizard

If question is asking flips required to get two heads in a row.

I get an answer of 6. Without discussion geometric series, there are two states the player can be in:

1. Initial state or last flip was tails (in other words two heads needed).
2. Last flip was heads (in other words, one head needed).

Let x = expected flips needed from state (1).
Let y = expected flips needed from state (2).

x = 1 + x/2 + y/2. In other words, after a flip, the player will have a 50/50 chance of being in state 1 or 2.
y = 1 + x/2. In other words, after a flip from state x, the player will either have achieved two heads or be back to state x.

Substituting the second equation into the first:

x = 1 + x/2 + (1 + x/2)/2
2x = 2 + x + (1 + x/2)
2x = 3 + (3/2)x
4x = 6 + 3x
x = 6

If question is asking flips required to get a total of two heads.

It takes an average of two flips to get each heads. Thus 2*2=4 flips required to get two heads.




Forgive me, I may have slightly misstated my intended problem statement here. I am trying to see the probability of getting "at least 2" heads before a tails in a fair coin toss, consecutively or non-consecutively, either way (both cases apply)?
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
February 28th, 2020 at 4:06:08 PM permalink
Quote: CasinoCrasher

Using,

S(n) = a + ar + ar^2 + ... +ar^(n-1) + ar^n

S(n) = a(1 - r^n) / (1-r)


There's one problem right there:

a (1 + r + r^2 + ... + r^n) = a (1 - r^(n+1)) / (1 - r), not a (1 - r^n) / (1 - r) as you stated.

For a = 2, n = 2, and r = 0.25, s(2) = 2 (1 - 0.25^3) / (1 - 0.25) = 2.625

Also, this formula works for all values of r other than 1 (if r = 1, S(n) = a (n + 1)).
The formula S(n) = 1 / (1 - r) for |r| < 1 only applies for n = positive infinity.

However, I don't think you are using geometric series (math note: it's called a "geometric series" if you're taking a sum, and a "geometric sequence" if it's just a list of numbers) correctly in this case.
First, determine the expected number of tosses to get one heads:
1/2 x 1 + 1/2 x 1/2 x 2 + (1/2)^2 x 1/2 x 3 + (1/2)^3 x 1/2 x 4 + ...
This is not a geometric series. However, if you rewrite it as:
1/2 x (1 + 1/2 x 2 + (1/2)^2 x 3 + (1/2)^3 x 4 + ...)
and then realize that (1 + 2x + 3x^2 + 4x^3 + ...) = (1 + x + x^2 + x^3 + ...)^2, it becomes:
1/2 x (1 + 1/2 + (1/2)^2 + (1/2)^3 + ...)^2
As you have already noted, since |1/2| < 1, then 1 + 1/2 + (1/2)^2 + (1/2)^3 + ... = 1 / (1 - 1/2) = 2, so the expected number is 1/2 x 2^2 = 2.
The expected number of tosses to get a second heads once you already have one is also 2, so the total is 2 + 2 = 4.
Doc
Doc
  • Threads: 46
  • Posts: 7287
Joined: Feb 27, 2010
February 28th, 2020 at 4:08:36 PM permalink
Quote: CasinoCrasher (1st statement)

I am wanting to use a geometric series to determine the number of trials or flips it takes in a fair coin toss to get 2 heads.



Quote: CasinoCrasher (2nd statement)

Forgive me, I may have slightly misstated my intended problem statement here. I am trying to see the probability of getting "at least 2" two heads before a tails in a fair coin toss, consecutively or non-consecutively, either way (both cases apply)?


I think these two statements ask two completely different questions, and neither of them is the question that the Wizard offered an answer for.

In my opinion, the second statement doesnt seem to make much sense. If you need at least two "heads" before a "tails", then the only successful trial is for the first two flips to both be "heads". Non-consecutive "heads" means there was a "tails" in between (unless the coin stands on edge, I suppose). I dont know about geometric series, but the probability of that one appears to be 0.5 * 0.5 = 0.25.

My original interpretation of your first statement of the problem was that you wanted to find the expected number of flips to get to your second heads, with zero, one, fifteen, or even a hundred tails possibly occurring along the way.

Conclusion: I still dont know what question you are asking.
CasinoCrasher
CasinoCrasher
  • Threads: 10
  • Posts: 41
Joined: Oct 4, 2015
March 1st, 2020 at 8:38:08 AM permalink
Quote: Doc

I think these two statements ask two completely different questions, and neither of them is the question that the Wizard offered an answer for.

In my opinion, the second statement doesn¡¯t seem to make much sense. If you need at least two "heads" before a "tails", then the only successful trial is for the first two flips to both be "heads". Non-consecutive "heads" means there was a "tails" in between (unless the coin stands on edge, I suppose). I don¡¯t know about geometric series, but the probability of that one appears to be 0.5 * 0.5 = 0.25.

My original interpretation of your first statement of the problem was that you wanted to find the expected number of flips to get to your second ¡°heads¡±, with zero, one, fifteen, or even a hundred ¡°tails¡± possibly occurring along the way.

Conclusion: I still don¡¯t know what question you are asking.



I agree, I completely butchered my problem statements. I was trying to make a simpler problem to understand the math behind a more difficult problem but, you just made me realize I can¡¯t relate the two. I am wanting to see the expected number of rolls before rolling 7 6s before a 7, consecutively or non-consecutively (both cases count), with two fair die. That is, the total number of rolls it takes to get to failure with failure being defined as 7 6s before a 7. The way I had this explained to me before included a geometric series which I am struggling to work through the math but, here it is ¡°(trials)*(6 or 7s/trail)*(average rolls/6 or 7) = average rolls (11/5)^7 * [1 - (5/11)^7] / (1-5/11) * 36/11 ¡Ö 1490.615¡±. Please show the calculation if you would be so kind for anyone answering.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
March 1st, 2020 at 2:52:44 PM permalink
Quote: CasinoCrasher

I am wanting to see the expected number of rolls before rolling 7 6s before a 7, consecutively or non-consecutively (both cases count), with two fair die. That is, the total number of rolls it takes to get to failure with failure being defined as 7 6s before a 7.


I am a little confused as to what, exactly, your problem is.

Are you asking, what is the expected number of rolls to roll 7 6s without rolling a 7, under the assumption that you won't roll a 7?
In that case, start with the expected number needed to roll one 6 without rolling a 7.
Since we are assuming that you will not roll a 7, any roll of 2 dice has 5 ways to roll 6 and 25 to roll something other than 6 or 7, so the probability of rolling a 6 is 1/6 and the probability of not rolling a 6 (or 7) is 5/6.
ER = 1 x 1/6 + 2 x 5/6 x 1/6 + 3 x (5/6)^2 x 1/6 + 4 x (5/6)^3 x 1/6 + ...
= 1/6 x (1 + 2 x 5/6 + 3 x (5/6)^2 + ...)
= 1/6 x (1 + 5/6 + (5/6)^2 + ...)^2
= 1/6 x (1 / (1 - 5/6))^2 = 6
The ER for a second 6 = 6 + the ER for the first 6 = 12
The ER for a third 6 = 6 + the ER for the first 6 = 18
and so on, until we get the ER for a seventh 6 = 42.

Remember, however, that this assumes that you never roll a 7.
I have a feeling you are asking a different problem - for example, maybe you want the number of rolls until you roll seven 6s since your most recent 7.
(The answer to this is about 1490 - of which just under 250 of the rolls will be 7s. It is, however, rather complicated, and has nothing to do with geometric sequences.)
Is that what you really want?
If not, then please give us some examples of what you mean - do not simply repeat the term "consecutively or non-consecutively" as that is unclear.
Last edited by: ThatDonGuy on Mar 1, 2020
Ace2
Ace2
  • Threads: 32
  • Posts: 2706
Joined: Oct 2, 2017
March 2nd, 2020 at 4:02:39 PM permalink
Quote: CasinoCrasher

1490.615¡±. .

I agree with that. We know that 7 sixes will be rolled before a seven with frequency (5/11)^7 = a. It will take an average of 1/a trials to accomplish that.

It will take 6 rolls, on average, to get the first seven and (1 - a) percentage of the time the seven will come before 7 sixes, so the expected trial length is 6 * (1 - a) rolls.

Therefore the expected number of rolls to get 7 sixes before a seven is:

1/a * 6 * (1 - a) =
(1/a - 1) * 6 =
1490.614733
Last edited by: Ace2 on Mar 2, 2020
Its all about making that GTA
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
March 3rd, 2020 at 8:15:31 AM permalink
^ Quick look I agree with Ace2 how long it takes before you start the winning roll. Then you add the winning roll itself.

Average #rolls to throw 7 6s before a 7.
Pr (Win) = (5/11)^7 0.004009048 249.4357888
Pr (Lose)=1 - a 0.995990952

Expected times you need before making a good roll = 1 in 249
So 249*6 is expected times before you start the winning roll
1490.614733

Expected rolls you need to roll 7 6's given you don't roll a 7 = (30/5)*7 = 42
So total is : 1532.614733
Ace2
Ace2
  • Threads: 32
  • Posts: 2706
Joined: Oct 2, 2017
March 3rd, 2020 at 11:42:07 AM permalink
Not sure I agree with that charliepatrick.

Quote: charliepatrick

Expected rolls you need to roll 7 6's given you don't roll a 7 = (30/5)*7 = 42

This ^^^ doesnt seem like valid logic since you cant temporarily stop 7s from coming. Theres always a 6/36 chance the next roll will be a 7

An average of 249.4 trials are needed for a success and each of these trials, including the successful one, have an average length of 6 * 248.4 / 249.4 = 5.976 rolls. 249.4 * 5.976 is 1490 rolls.

You can set up a system of linear equations to solve this as follows. X is the initial state with no sixes, a has 1 six, b has 2 sixes etc.

x = 1 + 5/36a + 31/36x
a = 1 + 25/36a + 5/36b + 6/36x
b = 1 + 25/36b + 5/36c + 6/36x
c = 1 + 25/36c + 5/36d + 6/36x
d = 1 + 25/36d + 5/36e + 6/36x
e = 1 + 25/36e + 5/36f + 6/36x
f = 1 + 25/36f + 6/36x

Im too busy right now to crunch through these (I know theres a way to do it in excel but I rarely use it). If you solve for x, I bet it will be 1490.615
Last edited by: Ace2 on Mar 3, 2020
Its all about making that GTA
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6738
Joined: Jun 22, 2011
March 3rd, 2020 at 5:40:32 PM permalink
Quote: Ace2

You can set up a system of linear equations to solve this as follows. X is the initial state with no sixes, a has 1 six, b has 2 sixes etc.

x = 1 + 5/36a + 31/36x
a = 1 + 25/36a + 5/36b + 6/36x
b = 1 + 25/36b + 5/36c + 6/36x
c = 1 + 25/36c + 5/36d + 6/36x
d = 1 + 25/36d + 5/36e + 6/36x
e = 1 + 25/36e + 5/36f + 6/36x
f = 1 + 25/36f + 6/36x

Im too busy right now to crunch through these (I know theres a way to do it in excel but I rarely use it). If you solve for x, I bet it will be 1490.615


You don't need Excel.
f = 1 + 25/36 f + 6/36 x -> 11/36 f = 1 + 6/36 x -> f = 36/11 + 6/11 x
e = 1 + 25/36e + 6/36x + 5/36f -> 11/36 e = 1 + 6/36 x + 5/36 f -> e = 36/11 + 6/11 x + 5/11 (36/11 + 6/11 x) = (36/11 + 6/11 x) (1 + 5/11)
d = 1 + 25/36e + 6/36x + 5/36e -> 11/36 d = 1 + 6/36 x + 5/36 e -> d = 36/11 + 6/11 x + 5/11 (36/11 + 6/11 x) (1 + 5/11) = (36/11 + 6/11 x) (1 + 5/11 + (5/11)^2)
You can continue in this way to get:
x = (36/11 + 6/11 x) (1 + 5/11 + (5/11)^2 + ... + (5/11)^6)
= 6/11 (6 + x) (1 - (5/11)^7) / (1 - 5/11)
= 6/11 (6 + x) (1 - (5/11)^7) 11/6
= (6 + x) (1 - (5/11)^7)
= 6 (1 - (5/11)^7) + (1 - (5/11)^7) x
x (1 - (1 - (5/11)^7)) = 6 (1 - (5/11)^7
x (5/11)^7 = 6 (1 - (5/11)^7
x = 6 (1 - (5/11)^7) / (5/11)^7 = 6 (11/5)^7 (1 - (5/11)^7) = 1490.6147

There's a rational number in there somewhere:
x = 6 * 11^7 / 5^7 * (11^7 - 5^7) / 11^7 = 6 (11^7 - 5^7) / 5^7 = 116454276 / 78125
This is a reduced fraction as the denominator is a power of a prime number and the numerator is not a multiple of that prime number
Ace2
Ace2
  • Threads: 32
  • Posts: 2706
Joined: Oct 2, 2017
March 3rd, 2020 at 6:46:39 PM permalink
I realize the equations can be solved with basic algebra. But hashing through them manually is just very tedious (in my opinion) when there are seven equations.

Thank you for solving them.
Its all about making that GTA
CasinoCrasher
CasinoCrasher
  • Threads: 10
  • Posts: 41
Joined: Oct 4, 2015
March 5th, 2020 at 7:22:11 PM permalink
Quote: Ace2

I agree with that. We know that 7 sixes will be rolled before a seven with frequency (5/11)^7 = a. It will take an average of 1/a trials to accomplish that.

It will take 6 rolls, on average, to get the first seven and (1 - a) percentage of the time the seven will come before 7 sixes, so the expected trial length is 6 * (1 - a) rolls.

Therefore the expected number of rolls to get 7 sixes before a seven is:

1/a * 6 * (1 - a) =
(1/a - 1) * 6 =
1490.614733



Hey, thanks Ace2, this is what I was looking to see. Is there a way to calculate how many times you would see only a single 6 before a 7 before you see the 7 6s before a 7. Similarily, how many times would you see only 2 6s before a 7 before seeing the 7 6s before a 7. So, to ask another way, how many times would you see only 1 6 before a 7 in 1490.614733 rolls?
Ace2
Ace2
  • Threads: 32
  • Posts: 2706
Joined: Oct 2, 2017
March 11th, 2020 at 1:44:28 PM permalink
Quote: CasinoCrasher

Hey, thanks Ace2, this is what I was looking to see. Is there a way to calculate how many times you would see only a single 6 before a 7 before you see the 7 6s before a 7

Not sure I understand the question or any practical application.

Anyway, the chance of rolling 7 or more sixes before a seven is (5/11)^7 = a. The probability of rolling exactly 1 six before a seven is 5/11 * 6/11 = b.

The probability of b happening before a is:

b / (a + b) = 98.4%
Its all about making that GTA
  • Jump to: