Thursday, January 25, 2007

The Gambler's Fallacy and the Law of Large Numbers

In its simplest form, the gambler's fallacy is to believe that, just because something hasn't happened for a while, it's due to happen soon. The usual example is a coin that comes up heads ten times in a row. The fallacious gambler thinks it has to come up tails soon - "the law of averages says it must!" But of course it needn't. The chances of the next toss being a tail remain 50-50, as they ever were.

There are occasions in which the gambler's reasoning might not be fallacious - for instance, if you were drawing cards from a pack without shuffling, each non-ace that was drawn would increase the chances of the next card being an ace - but in almost all gambling scenarios (at least in the casino and possibly excluding blackjack), there is no memory involved.

It's possible that the fallacious gambler is misremembering the Law of Large Numbers. This is a much misunderstood mathematical theorem - I once spent an entertaining breakfast arguing with a friend about this, much to the bemusement of everyone else in the backwater Wyoming diner. The Law says that, if you look at a random event for enough trials, the number of successes divided by the number of trials will get as close as you like to the probability. If you toss a million coins, you should end up with an observed probability of almost exactly 0.50. Unfortunately, that doesn't quite mean that you can put the bank on there being exactly 500,000 heads, though. In fact, the Law of Large Numbers even says how far away you can expect to be - in this case, on average you'll be within 500* tosses of that. I just ran a quick test, emptying my piggybank and tossing 1,000,000 coins a hundred times over**. I found:

  • the average set of tosses contained 499,978 heads
  • the standard deviation was about 460 - pretty close to what the Law predicts.
  • 97% of the observations were within 1000 of the real mean
  • 71% were within 500.
  • None were exactly 500,000 (or even within 10).

So the experiment conforms pretty much exactly with what the Law predicts.

* in general, the expected number of successes, each with probability p in N trials, is pN +/- sqrt(Np(p-1)). The square root is a standard deviation; 68% of the time, the answer will lie within one SD of the mean (pN); about 95% of the time, it'll be within two.

** My piggybank is entirely virtual. Code and results are available on request; if there's enough demand I might make a little javascript to demonstrate.

2 comments:

Yvonne Kertsch said...

Thank you for your article. I have been playing Martingale Roulette for years and everybody is telling me I am bound for disaster, but so far, disaster has not stroke yet :-)

As you rightly said, the odds of let say 10x heads or tails in a row is less than 0.02 percent.

Same as an ape writing "Romeo and Juliet" when sat before a typewriter.

Truely enjoyed your experiment. Best regards, Yvonne

kensson said...

Thanks for your comment, Yvonne, but you're playing a dangerous game!

Actually, ten losses in a row on a European wheel is about 1/800 - which is 0.13%, roughly the same as the probability of an ape writing the first two letters of Romeo and Juliet. On an American wheel, it's about 0.16%, which is even higher.

The chances of you surviving, say, 100 games is pretty good (88% in Europe, 85% in America), but that still translate into something like a 1/8 or 1/9 chance of losing all your money.