1

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

Max
  • 13
  • 2
  • 2
    Sounds like a great project. Why did you post here? Do you have a question? – abelenky Nov 30 '10 at 05:27
  • It's closely related to progressive bidding in a 50/50 casino game, where you start with a fixed sum X, if you lost you bid X*2, then X*4, etc. If you have an infinite buffer of money, you'll surely win this initial X at the end. – ruslik Nov 30 '10 at 05:57
  • The linked site doesn't work correctly because if you're paying $20 each time you DON'T win. it only works when the pay is up to about 2^3. – John Nov 30 '10 at 06:24
  • 3
    The statisticians at http://www.crossvalidated.com (aka http://stats.stackexchange.com ) are going to be able to help you out further. – Joris Meys Nov 30 '10 at 10:09

1 Answers1

3

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))
VitoshKa
  • 8,387
  • 3
  • 35
  • 59