No Double Heads

A casino owner invents a new game where a player flips a fair coin n n times in a row. If the player does not flip two heads in a row at any point in the n n flips, then he wins the game; otherwise the house wins.

To make the game popular, the casino owner wants to maximize the player's chance of winning. However, the casino needs to make a profit, so the house must win more than half of the games played over the long run.

What should the casino owner set n n to be?

4 5 6 7 8

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Mark Hennings
Sep 15, 2018

Let X n X_n be the number of ways of thowing n n coins without obtaining two successive heads. To count X n X_n , we note that if the first toss is H H , the second toss must be T T , while no restriction is placed on the second toss if the first toss is T T . Thus the number of ways of tossing n n coins without obtaining two successive heads, if the first toss is H H , is X n 2 X_{n-2} , while the number of ways of tossing n n coins without obtaining two successive heads, if the first toss is T T , is X n 1 X_{n-1} . Thus X n = X n 1 + X n 2 X_n \; = \; X_{n-1} + X_{n-2} Since it is easy to see that X 1 = 2 X_1 = 2 and X 2 = 3 X_2 = 3 , we deduce that X n = F n + 2 X_n = F_{n+2} can be expressed in terms of the Fibonacci numbers. Thus the probability that the customer wins, if n n coins are tossed, is p n = F n + 2 2 n p_n \; = \; \frac{F_{n+2}}{2^n} Note that 2 n + 1 ( p n p n + 1 ) = 2 F n + 2 F n + 3 = F n + 2 F n + 1 0 2^{n+1}(p_n - p_{n+1}) \; = \; 2F_{n+2} - F_{n+3} \;= \; F_{n+2} - F_{n+1} \;\ge \; 0 so that p n p_n is a decreasing sequence. We calculate p 1 = 1 p_1 = 1 , p 2 = 3 4 p_2 = \tfrac34 , p 3 = 5 8 p_3 = \tfrac58 , p 4 = 1 2 p_4 = \tfrac12 and p 5 = 13 32 < 1 2 p_5 = \tfrac{13}{32} < \tfrac12 . Thus the casino owner sets n = 5 n = \boxed{5} .

Great solution!

David Vreken - 2 years, 8 months ago

Log in to reply

If you go over the first cases manually you soon just find 5. I wish the problem was different so that you had to use Fibonacci. I only got to notice it while I already had the answer : )

Samuele Arcidiacono - 2 years, 8 months ago

Make use of Fibonacci is a great move, thanks!

Kelvin Hong - 2 years, 8 months ago

Sorry to ask you: I don't understand why should be X 1=2 and X 2 =3

Febs UNI - 2 years, 8 months ago

Log in to reply

If you toss one coin, the outcomes H and T are both OK. Thus X 1 = 2 X_1=2 . If you toss two coins, the outcomes HT, TH and TT are all OK (the only bad possibility is HH), so X 2 = 3 X_2=3 .

Mark Hennings - 2 years, 8 months ago

Log in to reply

Oh right, so 2^n less the number of possibilities to have 2 H in a row! Thank you! But if the condition had been "at least 2 Heads" instead of "just 2 Heads in a row", Fibonacci method doesn't work anymore right? Because in that case I will have: P1=1 , P2= 3/4 , P3=4/8=1/2 , P4=11/16 (and so the F_5 =/= 5 but 4 ) and I should say the optimal tosses is 4.. But I am not sure about this. Sorry for my ignorance.

Febs UNI - 2 years, 8 months ago
&Y Edwards
Sep 18, 2018

If the casino sets n = 4, then the punter's winning combinations (out of 16 possibilities) are TTTT, TTTH, TTHT, THTT, HTTT, HTHT,THTH and HTTH.

Any other combinations have consecutive Hs and hence lose.

With n = 4 the casino has an 8 out of 16 chance of winning so this is not acceptable.

Increasing n to 5 will decrease the punter's chance of a win; because there are 1 + 5 + 5 + 1 = 12 acceptable placements of 5, 4, 3 and 2 Ts in a set of five flips.

The punter has a 12 out of 32 chance of a win, so n = 5 fulfills the casino's requirement with a 20 out of 32 chance.

Make n bigger and the punter's chance of winning gets progressively worse.

See my proof. The punter's winning chance with n = 5 n=5 is 13 32 \tfrac{13}{32} . There are 6 6 patterns with 3 3 Ts (and not 5 5 ), namely HTHTT, HTTHT, HTTTH, THTHT, THTTH, TTHTH.

Mark Hennings - 2 years, 8 months ago

That's what I thought.. so I went with 8

Azad Beriwal - 2 years, 8 months ago
Vinod Kumar
Sep 17, 2018

In the general case, when the coin is fair and p=1/2, the formula for average number of tosses to get n consecutive heads=2^(n+1)-2.

So, set one less than this to favour the casino in case of two consecutive heads (n=2):

Answer=(2^3-2)-1=5

Nice concise solution!

David Vreken - 2 years, 8 months ago

You are assuming that the probability of being less than the expected value is 1 2 \tfrac12 . In other words, you are assuming that the expected value is equal to the median. This is not always true, which means your argument is incomplete.

Mark Hennings - 2 years, 8 months ago

Log in to reply

As 6, 7 or 8 will favour casino much more, I chose 5 as the best answer.

Vinod Kumar - 2 years, 8 months ago

Log in to reply

That's not the point. You are saying that since the expected number of tosses until 2 heads is 6 6 , then any number of tosses less than 6 6 will give the punter a less than 50 50 % chance of winning, so you give the punter the best chance (which the rules require you to do) by choosing 5 5 .

This argument would only be correct if the expected number of values was automatically the median, which is not correct. Consider the three random variables X 1 , X 2 , X 3 X_1,X_2,X_3 , where

  • X 1 X_1 takes values 2 , 4 , 8 2,4,8 with probabilities 1 2 , 1 4 , 1 4 \tfrac12,\tfrac14,\tfrac14 respectively,
  • X 2 X_2 takes values 0 , 4 , 6 0,4,6 with probabilities 0.3 , 0.1 , 0.6 0.3,0.1,0.6 respectively,
  • X 3 X_3 takes values 0 , 5 , 6 0,5,6 with probabilities 19 60 , 1 10 , 7 12 \tfrac{19}{60}, \tfrac{1}{10},\tfrac{7}{12} respectively.

All three random variables have expected value 4 4 , but P [ X 1 4 ] = 3 4 P[X_1 \le 4] = \tfrac34 , P [ X 2 4 ] = 0.4 P[X_2 \le 4] = 0.4 and P [ X 3 4 ] = 19 60 P[X_3 \le 4] = \tfrac{19}{60} , so none of these have median 4 4 . Indeed, if n j n_j is the largest achievable integer such that P [ X j n j ] < 1 2 P[X_j \le n_j] < \tfrac12 , then n 1 n_1 does not exist, n 2 = 4 n_2 = 4 , n 3 = 5 n_3 = 5 , so it is possible for n n to be less than, equal to, or greater than the expected value.

Mark Hennings - 2 years, 8 months ago

Something's not quite right... What you say would mean that the average number of tosses to get 2 consecutive heads would be 6, while it is actually 4.

C . - 2 years, 8 months ago

2 consecutive heads is good for the casino. If your argument works, and 6 is somehow a breakeven point, shouldn't you add one to favor the casino and end up at 7, which is an incorrect answer?

It is not about the average number of tosses to get n consecutive heads, but about the number of tosses where the probability of n heads in a row is greater than 50%.

In 1 toss the probability that the last toss contributed to 2 heads in a row is 0. At 2 tosses, the probability that the last toss contributed to 2 heads in a row is 1/4. For the remaining 3/4 of the sequences, in 3 tosses the probability that the last toss led to 2 heads in a row is 1/6. For the remaining 5/8 of the sequences, in 4 tosses the probability that the last toss led to 2 heads in a row is 1/5. For the remaining 1/2 of the sequences, in 5 tosses the probability that the last toss led to 2 heads in a row is 3/16, etc.

This is the point where >50% of the sequences contains 2 heads in a row. There still is a chance that it takes over 10, or even over 100 tosses to get two heads in a row. These also contribute to the number of tosses it takes on average to reach 2 heads in a row, because even though they are low-chance events they consist of a high number of tosses. In this problem, we're however not at all interested in this long tail of the distribution...

Roland van Vliembergen - 2 years, 8 months ago

Log in to reply

As I said in my comment (below), this solution is mixing up the expected value with the median. It is not automatic that P [ X n ] < 0.5 P[X \le n] < 0.5 when n < E [ X ] n < E[X]

Mark Hennings - 2 years, 8 months ago
Paul Cockburn
Sep 21, 2018

After each coin toss, define the current state as either Safe (S), Dangerous (D) or Lost (L) where S means the last toss was tails, D means the last toss was heads (and in both cases the sequence does not yet contain two consecutive heads) and L means that two consecutive heads have already been thrown. For the next toss, S could lead to S or D; D could lead to S or L; L will lead to L.

Hence we can calculate the new range of possibilities by the formula S(new) = S+D; D(new) = S; L(new) = 2L+D

Beginning with [S,D,L] = [1,1,0] after the first toss we generate the following:

2nd toss: [2,1,1]

3rd toss: [3,2,3]

4th toss: [5,3,8]

5th toss: [8,5,19]

It is with five tosses of the coin that the number of losses becomes greater than half the total number of possibilities.

Thomas Langerwerf
Sep 21, 2018

I just worked it out for 4, saw it was 50% and thus answered 5.

Golan Shabi
Sep 20, 2018

The chances of getting two heads in a row are (1/2)^2 per 2 throws. So theoretically every 8 throws you get head twice in a row at least once. Divide it by 2 and you get for every 4 throws a 50% chance of getting two heads in a row. the first number n that will give the casino the lowest chances that remain above 50% is 4+1 which is equal to 5

"every 8 throws you get head twice in a row at least once" - What if all 8 throws are tails?

David Vreken - 2 years, 8 months ago

Log in to reply

In a fair coin you have 2 options heads or tails. All of the combinations fron these 2 options are HH TT HT TH. Meaning if you throw a coin twice your chances of hitting heads twice in a row are 1/4 meaning 25%. And in 2 double throws it doubles meaning 2/4 which is 50%

Golan Shabi - 2 years, 8 months ago

Log in to reply

By this logic, 4 double throws would give 4/4 or a 100% chance of hitting heads twice in a row, but this is not true, as it is possible to throw a coin 8 times and get all tails. In fact, using @Mark Hennings method, we see that throwing a coin 8 times in a row would give a 201/256 or a 78.5% chance of hitting heads twice in a row.

David Vreken - 2 years, 8 months ago

Log in to reply

@David Vreken What i meant is that by the law of large numbers on average every 8 throws should have HH at least once, wasnt sure how to explain it and thats why i said theoretically. https://en.m.wikipedia.org/wiki/Law of large_numbers

Golan Shabi - 2 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...