"Jack takes a coin from his pocket and decides that he will flip it 4 times in a row, writing down the outcome of each flip on a scrap of paper. After he is done flipping, he will look at the flips that immediately followed an outcome of heads, and compute the relative frequency of heads on those flips. Because the coin is fair, Jack of course expects this empirical probability of heads to be equal to the true probability of flipping a heads: 0.5. Shockingly, Jack is wrong."
But actually Jack is right. Here are all the possibilities. A "streak" means a head was followed by a head, and a "break" means it was followed by a tail.
TTHT 0 1
TTHH 1 0
THTT 0 1
THTH 0 1
THHT 1 1
THHH 2 0
HTTT 0 1
HTTH 0 1
HTHT 0 2
HTHH 1 1
HHTT 1 1
HHTH 1 1
HHHT 2 1
HHHH 3 0
total 12 12
They get into some math, but just counting the cases doesn't seem to support their argument at all. If anyone can explain their argument in a simple way, I'm interested.
If they're really confident in this, they should go to Vegas, find a high-rolling gambler, and start betting on coin flips. After each heads, offer 55/45 odds that the next coin flip will be heads. I'm sure it won't be hard to find takers.
Consider this question, "You're somewhere in the middle of a 4 coin toss, and the last toss came up heads, what's the probability of the next one coming up heads?" I think the paper is saying it's a 40% chance -- you know you're in an finite series, and, you have partial information about that series.
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.
Code here https://github.com/gregryork/Flips/tree/master/src/flips
EDIT: Graph is empirical H|H against run length (output of the last function in a linear graph)
Or to put it another way, how would you structure a bar bet so you come out ahead?
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.
(Of course if I convincingly lose the bet, I learn a way to make a living on bar bets in Vegas, so I still win in the long run :)
But maybe I'm misinterpreting what they mean and there's some way to structure a bet so the odds fall to one side or the other. I just having found it yet. If we could find it and put it on paper, we'd have a clear understanding of why it works.
Plus, it'd probably be pretty counterintuitive and with a decent bankroll would be reliably profitable over the long term, in certain environments.
Your MC results are interesting, I've looked at your code and it seems straightforward. But counting all possible cases is essentially a mathematical proof, and I just can't find any mistakes in it, or figure out how it could be wrong.