Solving this numerically, I get 14414.
I used the following line of Mathematica code:
For[n=14400, Sum[PDF[BinomialDistribution[n,.51],k],{k,n/2+5,n}] < .99, n++, Null]; Print[n]
(I played around with it a little to guess the initial value of 14400, just so it wouldn't take forever to run....)
I did it in C, my code was a bit longer. (And it has the advantage that you do not need an initial estimate for the problem to be solved in a very short time.)
#include <math.h>
#include <stdio.h>
double p(int throws, double pwin, int req_wins)
{
int win, i;
double log_dp = log(pwin) * throws;
double log_loss_win = log((1 - pwin) / pwin);
double ret = 0;
for (win = throws, i = 0; win >= req_wins; win -= 2, ++i) {
ret += exp(log_dp);
log_dp += log_loss_win + log((throws - i) / (i + 1.0));
}
return ret;
}
int main()
{
double pwin = 0.51;
int req_wins = 10;
double conf = 0.99;
int min, max = 1;
while (p(max, pwin, req_wins) < conf)
max *= 2;
min = max / 2;
while (min < max) {
int mid = (min + max) / 2;
if (p(mid, pwin, req_wins) < conf)
min = mid + 1;
else
max = mid;
}
printf("For %d throws, P(win $10 or more) = %f\n"
"For %d throws, P(win $10 or more) = %f\n",
min - 1, p(min - 1, pwin, req_wins),
min, p(min, pwin, req_wins));
}
The output from this program: For 14413 throws, P(win $10 or more) = 0.989777
For 14414 throws, P(win $10 or more) = 0.990004
Re:Coin Flip Brain Teaser
by madcaptenor on Friday July 24, 2009 @12:16PM
(#721746)
I'm glad to see an answer from this approach. (Maple wasn't cooperating for me.) And notice that it compares well with the 14507 from the normal approximation to the binomial.
Re:Coin Flip Brain Teaser
by rarestblog on Friday July 24, 2009 @11:00AM
(#721551)
I think he was asking for a numeric answer.
If he wants one he can calculate it using the formula I've provided. A normal approximation to the binomial distribution might help too.
[deleted]
Re:Coin Flip Brain Teaser
by madcaptenor on Friday July 24, 2009 @11:43AM
(#721653)
The amount you win on a single flip has mean 0.02 and variance 0.9996. So the amount won after n flips, for large n, is approximately normally distributed with mean 0.02n and 0.9996n. (This uses the Central Limit theorem.)
The question, then, is to find n large enough that this has probability 0.99 of being at least 10. A normally distributed random variable has probability 0.99 of being at least 2.33 standard deviations below its mean, so we want to find n such that
0.02n - 2.33*sqrt(0.9996n) = 10
and solving for n (this is a quadratic equation in sqrt(n)) gives 14507.
(Your 10576 is what I get from my method if I look for 97.5% certainty.)
Yes, we used the wrong CDF. 14507 is what we get as well with the correct one.
Re:Coin Flip Brain Teaser
by zackattack on Friday July 24, 2009 @10:54AM
(#721533)
There's got to be a better way to express summations and combinations on the internet. Did you see that link posted earlier?
No I didn't. Could you please repost? I'd be interested.
Re:Coin Flip Brain Teaser
by zackattack on Friday July 24, 2009 @11:11AM
(#721588)
Re:Coin Flip Brain Teaser
by madcaptenor on Friday July 24, 2009 @11:57AM
(#721688)
Yeah, but that just tells you how to write the symbol in LaTeX. HN doesn't support LaTeX so that's no good. What tome wrote is basically LaTeX stripped of some of the syntax that makes it unambiguous for computers but hard to read for humans. This is basically the standard way of writing mathematics in a plain-text setting.
Re:Coin Flip Brain Teaser
by zackattack on Friday July 24, 2009 @12:53PM
(#721869)
You missed my intention. My point is that there's got to be a better way. That link shows important progress towards the next step: expressing equations, translating them into LaTeX, and then rendering them into image (e.g. png) form.
Re:Coin Flip Brain Teaser
by zackattack on Friday July 24, 2009 @10:50AM
(#721518)
What is W?
What is the minimum value of N such that P(2W - N >= 10) >= 0.99, i.e. P(W >= 5 + N/2) >= 0.99.
So calculate Sum from {n = 5 + N/2} to {n = N} of P(W = n) for some different values of N, and see what you get!
[P(W = n) = (N choose n) 0.51^n 0.49^(N-n)]