One of my favorite courses in college was “Experimental Economics”, where we examine how real live humans differ from *homo economicus*– the perfectly logical, profit-maximizing agent of classical economics.

A good example is the ultimatum game, a 2 player game where one person has $10, and suggests a way to split that $10. The second player can accept, and then they go on their merry way, or decline and both players get nothing. *Homo economicus* would accept $0.01, since she would be better off than when she started, but most of us would be pretty insulted by such an offer. Conversely, most of us probably would not offer only $0.01, even if it *is *the “best play”.

Another game I am intrigued by is called the St. Petersburg paradox, apparently first posed and studied by some combination of the Bernoulli family. The idea is that we will play a game where I flip a coin until it comes up tails. If it comes up heads *n* times in a row, you win dollars. The question is: *how much would you pay to play this game? *

A reasonable way to approach answering this is to compute that you have a 1/2 chance of winning $1, 1/4 chance of winning $2, 1/8 chance of winning $4, and so on. Hence, your “expected winnings” are , which is a divergent sum. This means that if I offer to let you play this game for $100, a “supremely logical” person would accept. Or for $1,000,000. Or any number. On the other hand, I know very few people who would pay even $10 to play the game. The wikipedia article above has plenty of good explanations for why, but this strikes me as a great example of where human behavior diverges from what is “optimum”.

Since I also like creating some content every once in a while, I also have a python script that plays this game using a random integer generator. Playing the game 10,000,000 times, the average payout was $11.66, and the largest payout was $4,194,304, meaning 22 heads in a row. This is somewhat meaningless, as we already calculated that the average payout will grow without bound as I perform more trials, but gives a feel for how much the game might be worth intuitively.

from random import randint def game(): coin = randint(0,1) count = 0 tot = 1 while coin != 0: tot+=2**(count) count +=1 coin = randint(0,1) return tot def lotsogame(N): tot = 0 top = 0 for j in range(N): n = game() tot += n if n>top: top = n return float(tot)/float(N), top print lotsogame(1000000)