A casino owner invents a new game where a player flips a fair coin n times in a row. If the player does not flip two heads in a row at any point in the 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 to be?
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.
Great solution!
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 : )
Make use of Fibonacci is a great move, thanks!
Sorry to ask you: I don't understand why should be X 1=2 and X 2 =3
Log in to reply
If you toss one coin, the outcomes H and T are both OK. Thus 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 .
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.
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 is 3 2 1 3 . There are 6 patterns with 3 Ts (and not 5 ), namely HTHTT, HTTHT, HTTTH, THTHT, THTTH, TTHTH.
That's what I thought.. so I went with 8
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!
You are assuming that the probability of being less than the expected value is 2 1 . 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.
Log in to reply
As 6, 7 or 8 will favour casino much more, I chose 5 as the best answer.
Log in to reply
That's not the point. You are saying that since the expected number of tosses until 2 heads is 6 , then any number of tosses less than 6 will give the punter a less than 5 0 % chance of winning, so you give the punter the best chance (which the rules require you to do) by choosing 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 , where
All three random variables have expected value 4 , but P [ X 1 ≤ 4 ] = 4 3 , P [ X 2 ≤ 4 ] = 0 . 4 and P [ X 3 ≤ 4 ] = 6 0 1 9 , so none of these have median 4 . Indeed, if n j is the largest achievable integer such that P [ X j ≤ n j ] < 2 1 , then n 1 does not exist, n 2 = 4 , n 3 = 5 , so it is possible for n to be less than, equal to, or greater than the expected value.
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.
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...
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 when n < E [ X ]
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.
I just worked it out for 4, saw it was 50% and thus answered 5.
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?
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%
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.
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
Problem Loading...
Note Loading...
Set Loading...
Let X n be the number of ways of thowing n coins without obtaining two successive heads. To count X n , we note that if the first toss is H , the second toss must be T , while no restriction is placed on the second toss if the first toss is T . Thus the number of ways of tossing n coins without obtaining two successive heads, if the first toss is H , is X n − 2 , while the number of ways of tossing n coins without obtaining two successive heads, if the first toss is T , is X n − 1 . Thus X n = X n − 1 + X n − 2 Since it is easy to see that X 1 = 2 and X 2 = 3 , we deduce that X n = F n + 2 can be expressed in terms of the Fibonacci numbers. Thus the probability that the customer wins, if n coins are tossed, is p n = 2 n F n + 2 Note that 2 n + 1 ( p n − p n + 1 ) = 2 F n + 2 − F n + 3 = F n + 2 − F n + 1 ≥ 0 so that p n is a decreasing sequence. We calculate p 1 = 1 , p 2 = 4 3 , p 3 = 8 5 , p 4 = 2 1 and p 5 = 3 2 1 3 < 2 1 . Thus the casino owner sets n = 5 .