This notebook is an element of the free risk-engineering.org courseware. It can be distributed under the terms of the Creative Commons Attribution-ShareAlike licence.

Author: Eric Marsden [email protected]

This notebook contains an exploration of the Saint Petersberg paradox, first proposed by Daniel Bernoulli around 1738. See the associated lecture slides for some background on the economic theory of risk aversion and decision-making on risk treatment.

## The rules of the game¶

You flip a coin repeatedly until a tail first appears. The pot starts at 1€ and doubles every time a head appears. You win whatever is in the pot the first time you throw tails and the game ends.

For example:

• T (tail on the first toss): win 1€
• H T (tail on the second toss): win 2€
• H H T: win 4€
• H H H T: win 8€

Which would you prefer?

• 10€ for sure
• the right to play the St. Petersburg game

## The expected value of playing¶

The probability of throwing a tail on a given round:

• 1st round: $\Pr(Tails) = ½$
• 2nd round: $\Pr(Heads) × \Pr(Tails) = ¼$
• 3rd round: $\Pr(Heads) × \Pr(Heads) × \Pr(Tails) = \frac{1}{8}$
• $k^{th}$ round: $\frac{1}{2k}$

How much can you expect to win on average?

• with probability ½ you win 1€, ¼ you win 2€, $\frac{1}{8}$ you win 4€, $\frac{1}{16}$ you win 8€ …
• $\mathbb{E}(win) = ½ + ½ + ½ + … = ∞$

The expected value of the game is infinite, yet few people would be willing to pay more than 20€ to play: this is what's known as “the St. Petersburg Paradox”.

## A Monte Carlo simulation of the expected value¶

Let's try to estimate the expected value of this game using a stochastic simulation.

In [26]:
import numpy, matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_formats=['svg']

def petersburg():
payoff = 1
while numpy.random.uniform() > 0.5:
payoff *= 2
return payoff

N = 1000000
games = numpy.zeros(N)
for i in range(N):
games[i] = petersburg()

In [27]:
plt.hist(numpy.log(games), alpha=0.5);

In [28]:
games.mean()

Out[28]:
13.426392

This game illustrates a situation where very unlikely events have an extremely high impact on the mean outcome: Monte Carlo simulation will not allow us to obtain a good estimation of the true (theoretical) expected value.

## The risk aversion explanation¶

Bernoulli suggested in 1738 that the “value” of a gamble is not its monetary value, but that people attach some subjective value, or utility, to monetary outcomes. Bernoulli's suggestion: people do not seek to maximize expected values, but instead maximize expected utility.

• marginal utility declines as wealth increases (poor people value increments in wealth more than rich people do)

• an individual is not necessarily twice as happy getting 200€ compared to 100€

• people are “risk averse”

This is a possible explanation for why very few people are willing to pay anything close to the theoretical value of playing this game.

## The “casino bust” explanation¶

Casinos are rich, but their riches are limited. Once you break their bank, they can't pay out any more, and thus the expected return is finite. Let's consider the case where the bank has a limit to their resources. We keep doubling the pot and halving the probability of winning the amount in the pot (half because you get the pot on a tail but not a head), until we reach the limit.

(This section was inspired by Peter Norvig's notebook on probabilities and paradoxes.)

In [29]:
def petersburg_finite(limit):
payoff = 1
while numpy.random.uniform() > 0.5:
payoff *= 2
if payoff > limit:
payoff = limit
break
return payoff


We can calculate the expected value of playing the Saint Petersburg game against a casino which has a finite limit to their bankroll. The expected value is the sum of the possible payoffs multiplied by their probabilities.

In [30]:
def expectation_petersburg_finite(limit):
expectation = 0
payoff = 1
probability = 1
while payoff < limit:
payoff *= 2
probability *= 0.5
expectation += payoff * probability
return expectation

In [31]:
expectation_petersburg_finite(1e8)

Out[31]:
27.0

So even with a fairly large casino backroll of 100 million euros, the expected value of this limited game is only moderate. Would you pay 27€ to have the possibility to play this game? If not, perhaps the risk aversion explanation above remains relevant…