Quote:
Originally Posted by David Sklansky
So how far from perfection was my instantaneous guesstimate 0f 7,100 out of 14,000?
The optimal strategy is to flip 14,852 times, and continue if you have 7,454 or more heads. That will give you an EV of $1652.10.
If you did 14,000 and 7,100, you would only have an EV of $1260.94. The optimal threshold for 14,000 flips is 7028 which would give an EV of $1650.51, better than 99% of optimal.
The formula for the ev is
ev = (.1*ph - .9*pt)*.02*(1000000-flip) - 0.016*flip
with
ph = 1-pbinom(thresh-1,flip,.51)
pt = 1-pbinom(thresh-1,flip,.49)
where
pbinom(k,n,p) is the cumulative binomial distribution for no more than k heads out of n flips with probability p.
To get the optimal strategy, I checked every strategy where we had had more than 50% heads all the way to 50,000 flips, and then went every 1000 after that up to a million, though that was hardly necessary. The R script below performs the brute force search, or as masque calls it, "brutal force" lol. You can put in different values for the parameters at the top.
Code:
start = 1
end = 50000
inc = 1
p.h = .1 # P(we have heady coin)
p.t = .9 # P(we have taily coin)
bias.h = .51 # P(heads with heady coin)
bias.t = .49 # P(heads with taily coin)
require(compiler)
enableJIT(3) # engage the afterburners
ev = function(flip, neg.edge, p.h, p.t, bias.h, bias.t) {
neg.ev = neg.edge*flip
thresh = ceiling(flip/2):flip
ph = 1-pbinom(thresh-1,flip,bias.h)
pt = 1-pbinom(thresh-1,flip,bias.t)
ev = (p.h*ph - p.t*pt)*.02*(1000000-flip) + neg.ev
m = max(ev)
c(m, thresh[min(which(ev == m))])
}
neg.edge = (.1 - .9)*.02
flips = as.list(seq(start,end,inc))
ev.thresh = sapply(flips, ev, neg.edge, p.h, p.t, bias.h, bias.t) # returns matrix of ev's and thresholds
ev.max = max(ev.thresh[1,])
k = min(which(ev.thresh[1,] == ev.max))
flips[[k]]
ev.thresh[2,k]
Output:
> flips[[k]]
[1] 14852
> ev.thresh[2,k]
[1] 7454
> ev.max
[1] 1652.098
Last edited by BruceZ; 05-27-2014 at 10:01 AM.