开发者

solving St Peterburg Paradox in R

St Petersburg paradox is a gambling game where you pay a fixed amount to enter the game. You flip a coin repeatedly until a tails is thrown. Your payoff is the sum from 1 to n of 2^n where n is the number of heads before the first tails. If that doesn't make sense try the wikipedia article

I was doing a paper on Expected Utility theory and was writing on the St Petersburg paradox and thought it would be neat(although not relevant to my paper) to try and do a monte carlo in R for how much you would expect to win after 10000 trials

I basically want to do 开发者_运维百科http://www.mathematik.com/Petersburg/Petersburg.html in R with 10,000 trials


This is easy in R. The game follows the geometric distribution with p=1/2:

N <- 1e+4
out <- replicate(N, mean(2^rgeom(1000, .5)))

Because the expected payoff of the game is infinity, you will get an extremely skewed empirical distribution which you won't even be able to depict properly:

hist(out)

Log scale might be a better idea.

hist(log(out))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜