Lenny Domnitser’s

⇙ Jump to content


This is a static archive of the domnit.org blog,
which Lenny Domnitser wrote between 2006 and 2009.

Soma-ch Spirit

I was finding it hard to get into the Christmas spirit, seeing as I’m a Jewish atheist, and it’s still November. Then I remembered the joy I got last year from SomaFM’s Xmas in Frisko, an “annual eclectic, irreverent holiday broadcast”. Thanksgiving is past, which means…it’s back!

Well, my heart lit up as I saw Xmas prominently displayed on Soma’s front page, and it melted when I heard the silly bumper between Louis Armstrong scatting and downbeat techno carols. It’s not really Christmas unless you share it, so here: have a listen. Enjoy it while you can—Christmas is only one twelfth of the year.

Latin-Cyrillic (English-Russian) Transliteration Tool

While I’m barely literate in Russian, I occasionally find the need to type some of it, and for a while the translit.ru transliteration service did a great job. The interface was dead simple: use your regular Latin/English keyboard to type chto-nibud' and что-нибудь automagically appears as the letters are entered. Now that site is was broken, so yesterday I hacked together my own transliterator.

Technical note: I tested on Firefox 2 and Opera 9; other browsers might be OK. Except for Internet Explorer 6–that’s definitely not OK.

This tool comes in several forms. The simplest is just like the old translit.ru: a big text area, and text is transliterated by Javascript as you type. However, as I was already writing my own code, I could also add a feature I always wanted from translit.ru: the ability to transliterate text fields on any web page. So, I also made a bookmarklet and Greasemonkey user script version, which add a little [cyr / lat] control next to every text box.

After installing the user script, be sure to open the script manager, select “Latin-Cyrillic (English-Russian) Transliteration Tool” and modify the Included Pages so that it only matches sites you actually want transliterated. Otherwise, you’ll see [cyr / lat] next to every text box.

If you use this and enjoy it, think a happy thought, and I will sense it, and be happy.

The St. Petersburg Paradox and Abstraction

Imagine this game: Flip a coin as many times as it takes to come up tails; call this n flips. You get paid $2n. How much would you pay to play this game?

Before you answer, consider another game. Roll a die, and get dollars equal to the value that appears. This game is worth its expected value—value times probability, summed for every possible outcome. This equals ⅙(1) + ⅙(2) + ⅙(3) + ⅙(4) + ⅙(5) + ⅙(6) = 3.5. A rational player would not pay more than $3.50 to play.

Let’s go back to the first game, and apply our technique of determining expected value. If the first toss is tails (half the time), you win $2, so that term in the expected value equation is (½)(2). If the first toss is heads (half the time) and the second toss is tails (half the time), you win $4. This adds to the expected value (½)(½)(4), or (½)2(2)2. In general, each possible outcome can be written as (½)n(2)n, and this always simplifies to 1. The expected value of every outcome is 1, and there are infinite outcomes, so expected value is: 1 + 1 + 1 + … = ∞.

Infinity? Is this supposed to mean that the average player of this game wins infinity dollars? That seems wrong. Also, if you were offered this game, the expected value tells you that you should be willing to pay any finite amount of money, such as your life savings, to then win infinite money. But you would be a fool to do so. This is called the St. Petersburg Paradox.

Realistic analyses of the paradox could try to circumvent that prickly infinity with the idea of limited resources and other economic arguments. An interesting result occurs when infinity is replaced with a large number, since nobody can really provide infinite money. The expected value of the game is changed dramatically if your winnings are capped at whatever can actually be paid to you. This table is shamelessly lifted from Wikipedia:

Backer Bankroll Expected value of lottery
Friendly game $64 $3.50
Millionaire $1,050,000 $10.50
Billionaire $1,075,000,000 $15.50
Bill Gates $51,000,000,000 (2005) $18.00
U.S. GDP $11.7 trillion (2004) $22.00
World GDP $40.9 trillion (2004) $23.00
Googolnaire $10100 $166.50


This gives some insight into why one would feel like the game isn’t worth a high bet, but it still does not resolve the problem theoretically, if any payout can be awarded.

In an article on the St. Petersburg Paradox in the Stanford Encyclopedia of Philosophy, Robert Martin dispels several other “realistic” explanations, and answers the question: in a purely theoretical version of the game, do statistical methods really break? According to the article, the rub is that our intuition about the game is tied to reality. There is a limit to the amount of money in the world, the amount of matter in the Universe with which to print money, the time we can spend flipping a coin, so we tell ourselves that under any realistic constraints, we could never gain infinite money. If we could sever ourselves from the real world, says Martin, infinite expected value is no paradox at all: “What it’s reasonable for real agents, limited in time, patience, bankroll, and imaginative capacity to do, given the constraints of the real casino, the real economy, and the real earth, is another matter, one that the theoretical core of decision theory can be forgiven for not specifying.”

What if, instead of money, unlimited and completely imagined points were used, and players just derived satisfaction from doing well in the game. Would they pay more to play? If instead of flipping a coin, a simple computer program determined and distributed points to the player? While this would not make the player’s time resource go to infinity, it will make it less limiting. Would this cause willingness to pay more? Would players pay more as the hardware running this program became faster? Actually, yes.

If, on average, a player can expect to win infinitely many dollars, or points, then if they play enough games, they will eventually get an arbitrarily large amount of money. If they can play enough times, and are not limited by the economy in the amount of debt they can enter before winning the big prize, then they can pay more. Consider this bit of Python code:

import random, sys

def play_once():
    n = 1
    while random.random() < 0.5:
        n += 1
    return 2 ** n

def achieve(fee, goal):
    games = 0
    total = 0
    while total < goal:
        total += play_once() - fee
        games += 1
    return games

Don’t worry; you don’t actually need to know any Python. The important bit is achieve(fee, goal), and all it does is play the game with a certain fee, until you make a certain amount of money: your goal. For example achieve(fee=20, goal=1000) will tell you how many games the computer played, paying 20 each time, until it won at least 1,000. This program does not reset you to zero every game, but stores your total, winnings or debts. Just running achieve(fee=20, goal=1000) a few times produces these game counts: 7,85; 3,659; 5; 1,575; 4,720; 1,67673; 1,742; 36,868. Each of these were completed in less than a second. Under such conditions, $20 seems like a pittance to pay, even if the goal is just $1,000.

What if the fee were a heftier $250, aiming for the same $1,000 total? The first run took 8 games, and an insignificant amount of time. The second attempt shot my CPU to 100% and ran hot and loud. After around twenty minutes, my limited time resource gave out and I left the casino. (I stopped the program.) Would I do the same thing ten years from now? Probably not, since my hardware will be a whole lot faster.

The program does one important thing: abstract away infinity. We can see that we can easily make a higher fee worth it, without changing the circumstances of the decision. My computer tried to hide reality from me, and I was able to achieve my $1,000 goal. Even with a $1,000,000 goal, the program never took more than a few seconds.

When I tried to increase the fee, the abstraction leaked, and I quit the simulator. But with faster hardware, paying $250 to eventually win $1,000 is not irrational. In fact, you can ask for as much as you want, which will presumably be infinity. (No? Commie!) Then, any finite fee is worth it. Paying less than “anything finite” is not the result of rational decision making, as it is classically defined, but of nasty but theoretically ignorable factors of mortality and thermodynamics. When God runs my code on his ∞-Hz ∞-bit 80∞86, there is no paradox.

Just try leaving reality.

Easy Reading

Don’t bother reading this; it’s boring.

Still here?

I took five minutes to hack together an “easy reading” stylesheet for this website, and then another five to fix a couple kinks. Try it.

Here’s what it looks like, half size:


Like it?

If I decide that this is actually something I want to keep, I can make it work with more browsers and across page reloads.