9
$\begingroup$

I am trying to find the expected value of the game in the St. Petersburg paradox. The game has infinite expected value, but in my simulation the payouts are about 15 on average, which is way too small.

Increasing iterations does increase the simulated mean but not much. Can anyone tell me or point to resources how to properly get such simulations to converge to their expected value, where events with very low probability are important? This is the code I used:

payout_list <- list()
B <- 1000000

for(i in 1:B){
  payout <- 1
  tails <- TRUE
  
  while(tails){
    payout <- 2*payout
    tails <- sample(c(T,F), size = 1)
  }
  payout_list <- append(payout_list, payout)
}

avg <- mean(as.numeric(payout_list))
$\endgroup$
3
  • $\begingroup$ importance sampling may be the way to go here. $\endgroup$ Commented Jul 29, 2022 at 19:39
  • $\begingroup$ It is worth to note Ole Peter's paper here The time resolution of the St Petersburg paradox $\endgroup$ Commented Jul 29, 2022 at 19:51
  • $\begingroup$ @JohnMadden I am familiar with importance sampling in general, but could you explain how one would apply the technique in this case? $\endgroup$
    – Lazlo
    Commented Jul 29, 2022 at 20:28

2 Answers 2

17
$\begingroup$

This is more a story of instability than of infinity.

You can spot the inexistence of a mean of a random variable $X$ by examining how the empirical mean changes over time. When the mean exists, eventually the mean of a long series of independent draws will settle down to the mean of $X:$ that is what various Laws of Large Numbers assert.

Now, although no finite simulation can definitively establish whether a mean exists or not, simulations can be suggestive.

As Wikipedia describes it,

A casino offers a game of chance for a single player in which a fair coin is tossed at each stage. The initial stake begins at 2 dollars and is doubled every time heads appears. The first time tails appears, the game ends and the player wins whatever is in the pot.

This game is certain to terminate, because the chance that it lasts longer than $n$ tosses is only $2^{-n},$ which can be made smaller than any positive number, showing that the chance the game does not terminate is less than all positive numbers: it must be zero.

The number of tosses follows a Geometric distribution, allowing for efficient simulation of this game, as in this R implementation of a million independent iterations.

X <- 1 + rgeom(1e6, 1/2)

A histogram of these results -- which are the binary logarithms of the winnings -- gives us a picture of their relative frequences. The steady decrease from $1/2$ for surviving just one roll, to $1/4,$ to $1/8,$ and so on, is apparent, indicating this simulation is doing the right thing.

Figure

The second panel plots mean winnings after each iteration. They don't appear to be settling down. The infinite expectation is manifest in the occasional large jumps. Think about what a jump must mean. The leap from near 20 to almost 25 around iteration 400,000, for instance, indicates the total winnings must suddenly have increased by about $(25 - 20)\times 4\times 10^5 \approx 2^{11}.$ It took a sequence of 11 tails in a row to do that. Every once in a while, going on as long as the game could ever be played, there will be such jumps.

Others have used simulations in the same way to analyze other situations with undefined or infinite means, such as a Cauchy random variable.

$\endgroup$
5
  • 1
    $\begingroup$ Thank you for the detailed answer! So the key issue is that the mean does not converge (which makes sense because it does not exist) and will keep slowly increasing. Are there ways to increase the rate at which it increases? $\endgroup$
    – Lazlo
    Commented Jul 29, 2022 at 20:27
  • 3
    $\begingroup$ Yes: run longer simulations. In a simulation of length $2^n,$ you can expect one win of $2^n,$ two wins of $2^{n-1},$ and so on down to $2^{n-1}$ wins of $2,$ for a mean of $n.$ That's why you and I are seeing means around $20$ or so (with lots of variation) in simulations of $1,000,000\approx 2^{20}.$ If, say, you were to run simulations of length $2^{25}\approx 34$ million, you would tend to see means around $25.$ Because that takes three seconds with my code, I ran it a few times and observed the expected behavior. $\endgroup$
    – whuber
    Commented Jul 29, 2022 at 20:38
  • 1
    $\begingroup$ These are nice looking plots/fonts; care to share the relevant code for that style? $\endgroup$
    – Ben
    Commented Jul 31, 2022 at 22:45
  • 2
    $\begingroup$ @Ben Thank you. This is work in progress. It involves many elements besides the fonts (such as the plotmath capability for labels), but the font helps a lot, so here's the relevant code. Begin with these three lines to load a Google font into R and name it "Informal": library(showtext); if(!("Informal" %in% font.families())) font_add_google("Fuzzy Bubbles", "Informal"); showtext_auto() To your plotting commands (base or ggplot) include the argument family = "Informal", as in hist(rexp(1e3), xlab=expression(log2(Winnings)), family="Informal") Eventually, execute showtext_end(). $\endgroup$
    – whuber
    Commented Aug 1, 2022 at 11:57
  • $\begingroup$ Looks really nice; I can't wait to see the work when it is finished! $\endgroup$
    – Ben
    Commented Aug 1, 2022 at 14:01
1
$\begingroup$

I'm not sure you can numerically simulate a process involving infinity. Every individual instance of the game terminates with a finite value, so any finite number of plays will result in the mean value also being finite. No matter how many times you simulate the game in practice, your simulation mean will never reach the expected value of the game, which is infinite.

The underlying issue is that a numerical simulation cannot converge to infinity - numerical models produce numerical results, but infinity isn't a number. At best, your simulation can return a very large number, but that does not itself imply that the process actually converges to an infinite expected value.

$\endgroup$
3
  • 1
    $\begingroup$ There are no infinities in the St. Petersburg game. It has a 100% chance of terminating after a finite number of moves. $\endgroup$
    – whuber
    Commented Jul 29, 2022 at 19:09
  • 2
    $\begingroup$ @whuber The expected value of the game is infinite, I would certainly characterize it as a process involving infinity, despite the fact that each instance of the game indeed has finite length and winnings. $\endgroup$ Commented Jul 29, 2022 at 19:13
  • 1
    $\begingroup$ That is incorrect. There is a stark difference between a realized infinity and a limiting process. $\endgroup$
    – whuber
    Commented Jul 29, 2022 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.