News for hackers. Stuff that matters.
Re:Coin Flip Brain Teaser by dadkins on Friday July 24, 2009 @12:07PM (#721721)
Let X be a random variable indicating the number of heads that have come up. After n flips, E[x] = pn, where p = 0.51 in our case. When X >= n/2 + 5, we're up 10 dollars.

In other words, we want to find n such that

Pr[X < n/2 + 5] < .01

If we express that in terms of the mean, we can apply a Chernoff bound:

Pr[X <= E[X] - a] <= Exp[-2a^2/n], for 0 < a < E[X]

If E[x] = pn, then a = pn - (n/2 + 5), which for p = 0.51 is a = .01n - 5.

So, solving Exp[-2a^2/n] = .01 (with help from Wolfram alpha) gives a quadratic equation with two solutions:

n = 348.257 and n = 651.743

The first is too small, a would be negative (n needs to be at least 500). The second is good enough.

652 does the trick.

Re:Coin Flip Brain Teaser by madcaptenor on Friday July 24, 2009 @12:21PM (#721760)
I like the idea of using a Chernoff bound, but 652 is way too low to be the answer!

But I get, as solutions for exp(-2(.01n-5)^2 / n) = .01, n = 10.4 and n = 24015.

Re:Coin Flip Brain Teaser by dadkins on Friday July 24, 2009 @12:24PM (#721771)
Oh you're right, that's the solution. Silly me, the moment I go to a computer to solve the final equation I get it wrong!