# St. Petersburg Paradox

**R – Predictive Hacks**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The fair premium in lottery games can be defined as the expected pay-off. For example, consider the game where you roll the die once and you get paid the face value in dollars. So, if you roll 1 you get **$1**, if you roll 2 you get** $2,** and so on. Then, the fair price to enter the game is the expected payoff which is:

\(E[X] = \sum_{i=1}^{6} x \times p(x) = \)

\(= \frac{1}{6}\times1 + \frac{1}{6}\times2+ \frac{1}{6}\times3+ \frac{1}{6}\times4+ \frac{1}{6}\times1+ \frac{1}{6}\times5+\frac{1}{6}\times6 = 3.5\)

In this case, the fair price which makes the game to be “zero-sum” is **3.5$**.

However, **in all lottery games**, the premium amount is higher than the expected return. Take as an example of the roulette games where the casino has the margin equal to 1/37 due to the number 0. Consider also the KENO game where the player is expected to lose 30% of the betting amount. The same applies to sports betting where the bookmaker has always a margin of around 6% which increases in multiple bets. Not to mention the slot machines and other casino games.

Someone could wonder, why these games are still so popular although the majority of people know that it is expected to lose by entering these games.

This question can be answered by taking into consideration the Expected Utility Hypothesis and the Utility function of each player. In plain English, the utility function is the calculation of how much someone desires something and it is different from person to person. Take as an example your “utility”, let’s call it pleasure, if you earn suddenly **$100,000** and what will be the “utility” of the same amount for Jeff Bezos. The $100K for Bezos is like $1 or 10$ for an average person.

## The St. Petersburg Paradox

The St. Petersburg paradox is based on a theoretical lottery game that leads to a random variable with infinite expected value but nevertheless, the people are willing to pay a relatively small amount to play this game.

**The Game**

A fair coin is flipped until it comes up heads the first time. At that point, the player wins $\(2^n\) where n is the number of times the coin was flipped. How much should one be willing to pay for playing this game?

If the coin lands heads on the first flip you win $2, if it lands heads on the second flip you win $4, and if this happens on the third flip you win $8, and so on.

**The Expected Payoff**

\(E[X] =\frac{1}{2}\times2 + \frac{1}{4}\times4 + \frac{1}{8}\times8+\frac{1}{16}\times16+…=\)

\(= 1+1+1+1+1+…=\infty\)

**The Paradox**

Although the expected payoff of this game is an infinite value, the participants are willing to pay a much smaller amount to enter the game. But what is a “fair” amount for most of the people to enter the game? Clearly, the value much is higher than $2, since this is the minimum payoff. Some studies have shown that the average amount is around $25.

The answer to this “strange” behavior can be found again in the field of Decision Theory and the expected utility hypothesis. We need to think about the payoffs of this game and their corresponding probabilities. So, in theory, you can get an extremely high amount but with an extremely low probability.

**Simulate the Game 1M Times**

Although we can easily calculate all the possible outcomes, it will be helpful to simulate this game 1M times. Below you can see the R code:

payoffs<-c() for (i in 1:1000000) { k<-1 while (sample(c("H","T"),1)!="H") { k=k+1 } payoffs<-c(payoffs, 2**k) } summary(payoffs)

The output:

Min. 1st Qu. Median Mean 3rd Qu. Max. 2.0 2.0 4.0 20.9 8.0 1048576.0

And the standard deviation was equal to **1753.074**. Note that the actual median of the game is 2 instead of 4.

As we can see, the average amount was **$20.9** and the maximum amount **$1,048,576** (flipped head at the 20th time).

Let’s assume that the payoff was 2 cents, 4 cents, 8 cents instead of $2, $4, $8,… Then, maybe the price to enter the game was not 25 cents(i.e. 0.25$) but a larger value. In this case, you could find players that are willing to pay $2 hoping to get a $100K. This is an example of how we perceive money. The premium amount that we are willing to pay is different when we change the value of the 1 unit measure (**1 unit = 1$** vs **1 unit = 1 cent**).

**leave a comment**for the author, please follow the link and comment on their blog:

**R – Predictive Hacks**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.