# The St. Petersburg Paradox and Utility Function

# The Paradox

The `St. Petersburg paradox`

describes a game of chance for a single player in which a fair coin is tossed at each stage. The initial stake starts 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.

Let denote the final winning amount after the th toss. We know that and and . We can see that is a sub-martingale as .

Let denote the minimum number of toss that shows a tail toss . is a stopping time.

The variance:

Considering nothing but the expected value of the net change in one’s monetary wealth, one should therefore play the game at any price if offered the opportunity. Yet the paradox exists between what people seem willing to pay to enter the game and the infinite expected value.

# The Martingale

With slight modifications from above, the `St. Petersburg martingale`

is the sequence of random variable , where and and . It is now a martingale because .

Note that now the expected payoff at inception is equal to initial stake based on Doob’s Idenfity, given stopping time T defined above:

# Expected Utility Theory

The classic way to resolve the paradox involves the introduction of utility function and the presumption of diminishing marginal utility.

Let `x`

denote a person’s total wealth, then the logrithmic utility function states that:

Where the marginal utility is a decreasing function of x:

Now we calculate the maximum cost `c`

that a person with logrithmic utility function and wealth `w`

would pay to enter the game. The maximum cost will make the expected utility change from playing the game be 0.

# Simulation

Given `w`

, `c`

can be calculated numerically. In python, we first check the maximum power of two allowed in our simulation. It turns out to be 63:

1 | import sys |

Returns:

1 | maximum integer: 9223372036854775807 |

## Logrithmic Utility Function

Now we use fsolve to calculate the maximum `c`

to break even:

1 | import numpy as np |

When w = 1000:

1 | maximum cost to enter: 10.95 |

When w = 1000000:

1 | maximum cost to enter: 20.87 |

## Square-Root Utility Function

1 | import numpy as np |

When w = 1000:

1 | maximum cost to enter: 12.93 |

When w = 1000000:

1 | maximum cost to enter: 22.87 |

Note that under the square-root utility function, the maximum cost to enter is higher, as utility diminished slower.

Reference: