6 ms·
Very naive Monte Carlo: https://gist.github.com/arnists/228c4e77b1e2aa6d33f1 https://gist.github.com/arnists/228c4e77b1e2aa6d33f1 Consistently comes back aroun
by Beltiras 11y ago
Very naive Monte Carlo: https://gist.github.com/arnists/228c4e77b1e2aa6d33f1 https://gist.github.com/arnists/228c4e77b1e2aa6d33f1
Consistently comes back around p. 50 runs have a span of .25%.
Haven't read the paper yet, but if the PRNG isn't broken, I'd say it invalidates the naive presentation at the start of the article.
EDIT: I think I understand the fallacy the authors present. This holds true for short runs. E(H|H) will be lower in short runs but asymptotically approaches p when number of trials rise.
- gtr 11y agoI enumerated the sequences that the article mentioned, and counted how often a tail filled a head, and vice versa, and got 12 instances where a head follows a head, and 10 where a tail followed a head. So there is a difference for just counting up all the possible 4 flip sequences where at least one of the first three is a head. However, doing a randomised test where I generated a random 4 length sequence, rejecting it if none of the first three was a head, then doing the same test showed no real difference. Code here https://github.com/gregryork/Flips/tree/master/src/flips https://github.com/gregryork/Flips/tree/master/src/flips
- Beltiras 11y agoTake a look at the updated gist. There's an asymptote for P(H|H) when trials grow approaching p. EDIT: Graph is empirical H|H against run length (output of the last function in a linear graph)
- gtr 11y agoI'm not really sure what I am looking at there. Is the X axis the number of trials run, or the length of the run?
- DennisP 11y agoWhat do you mean by short runs? If you mean just the total sample of 4, probability H|H is .5.
- Beltiras 11y agoActually my MC predicts below 40%, authors state 42%. See the graph in the gist. It plots the last function in the gist.
- DennisP 11y agoOk but how? There are only 14 cases. I enumerated them all and got 50% heads given previous heads. How are you counting? Or to put it another way, how would you structure a bar bet so you come out ahead?
- Beltiras 11y agoBet even money on a coin flip you choose from a set of 4, discarding first toss. Bet against last result every time. This would maximize your gain if the results hold. I'm not convinced they do, but the MC suggests it does.
- DennisP 11y agoGive me a slight edge over 50% and I would take that bet.
- Beltiras 11y agoUpdated the gist with test code for this bet. With runs of 1000 4 coin runs, you sometimes lose and sometimes win, but trend is you win more than you lose. You can play with the numbers to figure out where the long-term odds work against you, but a bar-bet designed by me should favor me so I wouldn't give you better odds than 50%. Fair-coin rule of bar-betting see? There are large fluctuations in this bet. sum([test_hothand(0.5,3) for i in xrange(10)]) has returned a range of (-348,+312) but biased towards positive for the patron. A combination of 10^6 runs was 320 wins in favor of the patron. sum([sum([test_hothand(0.5,3) for i in xrange(10)]) for x in xrange(10)]) fluctuates too but it's sum is still in favour of the patron.