Question

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

Was it helpful?

Solution

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))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top