The gambler’s fallacy killed by pure maths
12 June, 2007 – 10:15 amStatistics (and the ability to gather/present) are an essential tool for performance testing. At the time of learning basic stats in high school and university I was plagued with the problem of not seeing the real life application of these tools. Sure, exercises and scenarios conducted simulated real life, but in reality, the meaning of stats escaped me. Fast forward 10 years and I am now rediscovering the joy of such measurements. In fact, those university text books get more of a workout now than previously during study.
I have already posted a few times about presenting stats using common tools like Microsoft Excel. I am still learning the stats package ‘r’ as I see that to be more powerful and extensible. In the interim I use a combination of Excel, MySQL and PHP to prepare and analyse stats. As this contract winds down and I prepare for the next, I’ve come across a useful application of stats to keep me entertained.
A friend of mine recently stumbled across a well known roulette strategy called the martingale strategy.
Originally, martingale referred to a class of betting strategies popular in 18th century France. The simplest of these strategies was designed for a game in which the gambler wins his stake if a coin comes up heads and loses it if the coin comes up tails. The strategy had the gambler double his bet after every loss , so that the first win would recover all previous losses plus win a profit equal to the original stake. Since a gambler with infinite wealth will with probability of 1 eventually flip heads, the martingale betting strategy was seen as a sure thing by those who practiced it…
So how can you lose? My friend and I put this to test after a few bourbons and a couple of beers. In the two times we’ve met since, we have both walked away winners, smug in our victory and laughing all the way back to the ATM… Obviously, casinos would have a counter to this though?
Stacked Odds
The first point that will work against us in the long run is basic probability. On an American roulette table (which predominates here in Australia) there are 18 red, 18 black and 2 green positions. A total of 38 possible outcomes. The addition of the 2 green positions are the first part of the casino’s counter attack. It tips the probability in their favour, since if you land on a green and you are betting on red or black (which is the strategy), you will lose regardless.
So if we were betting on either red or black, there is a probability of 18/38 that we will win, and 37/38 that we will lose:
18/38 = 47.36% chance to win
20/38 = 52.64% chance to lose
So from the outset, probability wise, we are more likely to lose than win, simply by the casino adding two green numbers (0 and 00). However, it is still likely to be the most fairest bet in the casino if you are hankering to gamble.
Coincidentally, if you add the winning numbers 1 to 36, you come up with the number 666. Hmmm.
Expected Value
This is also known as the House’s Edge, but in probability theory, the expected value of a random variable is the sum of the probability of each possible outcome multiplied by the outcome value (or in this case your winnings). So for the American roulette table with probability of losing being 20/38 and probability of winning being 18/38, the expected outcome value for a $1 bet is:
(-$1 x 20/38) + ($1 x 18/38) = -$0.0526316
Therefore on average for every dollar bet the expected value of one dollar is:
$1 - $0.0526316 = $0.95
So your net gain is less than what you started with. Statistically, this is not a fair bet.
Gambler’s Fallacy
Perhaps the next biggest problem with this strategy, is the simple human tendency to try and recognize patterns. You will hear my friend say that it is extremely unlikely for the play to fall red, black, red, black, red, black and so on. If this happens, and you follow the strategy you will lose quickly, because you will be forced to double each losing bet ($5, $10, $20, $40, $80, $160, $320) …
Despite human intuition telling us that the next play can’t possibly be another black, or it can’t possibly be another red, or it can’t possibly alternate between red and black I mean, come on, how likely is that? The reality is, each roll is statistically independent. That is, between two spins of the wheel, the occurence of one black or one red is neither more nor less proabable than the other occurring. The human trait of identifying lucky streaks, or patterns in play is precisely what casinos prey upon. In fact, casinos no doubt go through painstaking measures to ensure that the roulette tables are balanced, because if not, then they risk people using more detailed statistical analysis to recognise patterns for a particular table. This is probably why roulette calculators are banned. In any case, don’t be fooled by the hype. Or at least that’s what I try and convince myself.
The Maximum Bet
It is possible to lose more individual games than win but still win money overall. Assuming you make bets that are a small percentage of your bankroll (<1%) so for a $500 bankroll you should stick to bets of $5. The bigger your bankroll the better. This is what makes the martingale strategy seemingly unbeatable as my friend and I chuckled to ourselves with suspicious glances from the croupier ... However, perhaps the most effective counter attack at the casino's disposal is the application of a house rule that specifies what the maximum bet for a table can be. For instance, on a $5 minimum bet table, you will often see $500 as the maximum bet. Why? because this limits the amount of money that a player can progressively double after losses. For example, if you start with $5 and lose, then following the strategy until you win again you will place $10, $20, $40, $80, $160 and $320 before you hit the maximum bet limit. That means you only have to lose around 6 times in a row before your strategy falls apart. Coincidentally, the odds of losing 6 straight games is quite high where 56.2% ^ 6 is approx 1/47. In the short term this doesn't seem too bad, but over a long term, coupled with the other points highlighted in this post I can guarantee one thing.
Statistically you will lose.
However, in the interests of having a great night out, and not throwing your money away on the pokies, or pointlessly trying to count cards on the black jack table, the martingale strategy keeps the night entertaining. Now try to explain all of this next time you’re drunk.
If you’re still not convinced, I wrote a perl script to help simulate the martingale strategy. In the following program, the defaults can be controlled via command line arguments, or you can follow my strategy which I plan to unleash on Queenstown casinos during my upcoming holidays to New Zealand. I’m not too sure which has the greater probability, me winning, or decent snow falls in July…
#!/usr/bin/perl -w
# ------------------------------------------------------------------------–
# Martingale Roulette Betting System Simulator
#
# Usage : Roulette.pl [options]
# Options :
# -bet minimum bet amount
# -atm amount of money to withdraw from ATM each night
# -maxBets maximum number of bets to place each night
# -maxBet maximum bet amount permitted by house rules
# -nightsOut number of nights to visit the casino
# -verbose optional [true] flag for verbose results
# -quit quite when you're [n] times ahead
# -fair optional [false] flag to remove casino edge
#
# $Revision: 1.3 $
# $Date: 2007/06/07 08:43:11 $
#
# Author: tim.koopmans@90kts.com [http://90kts.com]
# ------------------------------------------------------------------------–
use Getopt::Long;
my %opts=();
GetOptions(
"bet=f" => \$opts{bet},
"atm=i" => \$opts{atm},
"maxBets=i" => \$opts{maxBets},
"maxBet=i" => \$opts{maxBet},
"nightsOut=i" => \$opts{nightsOut},
"quit=f" => \$opts{quit},
"fair=s" => \$opts{fair},
"verbose=s" => \$opts{verbose}
);
my $bet = $opts{bet} || 5;
my $atm = $opts{atm} || 100;
my $maxBets = $opts{maxBets} || 50;
my $maxBet = $opts{maxBet} || 500;
my $nightsOut = $opts{nightsOut} || 15;
my $quit = $opts{quit} || 1;
my $fair = $opts{fair};
my $verbose = $opts{verbose};
my $wager = $bet;
my $kitty = $atm;
my $betColour = "BLACK"; # Starting colour to bet
for ($n=1; $n<=$nightsOut;$n++)
{
for ($i=1;$i<=$maxBets;$i++)
{
# Subtract your wager from your kitty ...
$kitty-=$wager;
# Spin that wheel ...
my @reds = (1,3,5,7,9, 12,14,16,18,19,21,23,25,27,30,32,34,36);
my @blacks = (2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35);
my @greens = (37,38); # American roulette table being used ...
if($fair) {
$spin = int(rand(36));
} else {
$spin = int(rand(38));
}
if ($spin%2==0) { $result = "EVEN"; }
else { $result = "ODD"; }
foreach (@reds) {
if ($_ == $spin) { $colour = "RED"; $ws=" "; }
}
foreach (@blacks) {
if ($_ == $spin) { $colour = "BLACK"; $ws=""; }
}
foreach (@greens) {
if ($_ == $spin) {
$colour = "GREEN";
$result = "--";
}
if ($spin==37) { $spin = "0"; }
elsif($spin==38) { $spin = "0"; }
}
if ($betColour =~ /$colour/) {
# Winner!
# Add the winnings to the kitty ...
$kitty += (2 * $wager);
if($verbose) { print "$ws$spin \t\tBet $wager \tWon $wager \t Kitty $kitty"; }
$wager = $bet;
}
else {
# Loser!
if ( ($kitty - (2 * $wager) ) < 0) {
# You can't afford to play on, double is more than you can afford tonight ...
if($verbose) {
print "$ws$spin \t\tBet $wager \tLost ".$wager." \t Bust $kitty";
}
#$i=$maxBets;
if($kitty>0){
$wager=$kitty;
} else {
$i = $maxBets;
}
} elsif ( (2 * $wager) > $maxBet) {
if($fair) {
$wager = 2 * $wager;
} else {
# You have reached maximum bet permitted by house rules ...
if($verbose) { print "$ws$spin \t\tBet $wager \tMax ".$wager." \t Kitty $kitty"; }
$wager = $maxBet;
}
} else {
# Double the wager and bet on the losing colour ...
if($verbose) { print "$ws$spin \t\tBet $wager \tLost ".$wager." \t Kitty $kitty"; }
$wager = 2 * $wager;
}
}
$betColour = $colour;
if($verbose) { print "\t$colour, $result\n";}
if($quit>1){
if($kitty > ( $quit * $atm) ){
# Quit while you're ahead tonight a [n] times atm ...
if($verbose) { print "$ws$spin \t\tBet $wager \tQuit ".$wager." \t Kitty $kitty\n"; }
$i=$maxBets;
}
}
}
$wager = $bet;
# Winnings tonight ...
if($verbose) {
print "------------------------------------------------------\n";
print "\$$kitty.00 \tTotal winnings on night $n\n";
print "\$".($kitty-$atm).".00 \tless ATM debt\n\n";
} else {
print "\$$kitty.00\n";
}
$totalWinnings+=$kitty;
# Withdraw from your ATM for the next night like a sucker that you are ...
$kitty=$atm;
# Keep track of your winnings though ...
$totalWinnings-=$atm;
}
# Summary statistics
print "\n------------------------------------------------------\n";
print "$bet \tMinimum bet\n";
print "$maxBet \tMaximum bet permitted by house rules\n";
print "$maxBets \tMaximum number of bets placed in one night\n";
print "".($n-1)." \tTotal nights out at casino\n";
print "\$$totalWinnings.00 \tTotal winnings less ATM debt\n";
print "------------------------------------------------------\n";









3 Responses to “The gambler’s fallacy killed by pure maths”
Hey koops,
interesting. Statistically you are right. But patterns do occur in nature, and the table most of the time does follow runs of colour rather than alternating. You have seen it and i have seen it. We have won both times, and i have lost only 3 times that i can remember using this strategy. Providing you stick to the limit you start out with to lose and win, if you win most of the time you will stay ahead reguardless of what statistics states. Remember they are an approximation of the real world, in the real world over 1000 or whatever spins the casino seems ahead statistically but generally isn’t when you use this strategy. When you lose, only lose the amount you started with limiting your losses. Each time you go if you start with 200 max, leave at say $150 winnings, generally win most of the time, say 80% which is conservative given my experience so far, then after 10 visits you have lost $400 but won $1200 therefore ahead $800. To break even using this strategy using these limits you would have to lose more than 40 % of the time. My experience does not even come close to this. I agree if you keep betting and playing forever with out stopping and starting again with limits then you will lose as those 6 in a row alternating numbers come up then a green, you reach the maximum bet and are cleaned out, but if you stick to the limits you will hopefully avoid that particular moment in time in which the nightmare event occurs occurs, because it DOES occur uncommonly. Each spin is independent and 50:50 but the statistical chance of alternating for six spins is low. You can do the maths.
Love ya
By Karpa on Jun 18, 2007
I was telling you at lunch “It is best just not to gamble”. I think you have said it best with “Statistically you will lose”. We both mean the same thing.
By Ted on Jun 18, 2007
Karps, if we were to write a dictionary definition of gambler’s fallacy we could use your belief almost verbatim. No offence! Even though you acknowledge statistical independence for each play, you still refer to patterns. That is a common mistake. For example, we know that the probability of losing any spin is:
20/38 * 100 = 52.6%So we can say before we play that the probability of losing six times in a row is:
0.526 ^ 6 = 2.12% chance or 1 in every 47 possible outcomesHowever whilst that theory acknowledges the possibility for a particular pattern to occur (black, red, black, red, black, red) it still does not nullify the statistical probability that between every spin, we always have a 52.6% of choosing the wrong colour!
Using your suggested strategy, I ran it through the simulation 2,000 times:
./Roulette.pl -nightsOut 2000 -atm 200 -maxBets 250 -quit 1.75In that simulation I am betting a maximum of 250 times per night (about 1 bet every 1.5 minutes = approx 6 hours at the table) over 2000 nights (to build some statistical validity into our results) and quitting when I am 1.75 times ahead (or $150 winnings as you said) or I have lost my atm balance for that night ($200). Sadly, it is nowhere near to winning 80% of the time as you predict. In my simulation, it was closer to 48.2% of the time. A net loss after 2000 nights of $57,500 …
I also modified my code to remove the casino’s edge with an addtional argument
./Roulette.pl -nightsOut 2000 -atm 200 -maxBets 250 -quit 1.75 -fair trueThis removes the max bet limitation of $500 per table (not applicable for a $200 atm bankroll) and also eliminates the two green positions. Both of which give the casino the slight edge required. This time I was winning approximately 62.8% of the time, which gave me a net gain of $46,000 …
So you can see quite simply, over time you will always lose as long as the casino maintains an edge.
This does not rule out sheer luck, perhaps on the nights you have gone out you have fallen onto the right side of the distribution, but ultimately, if you stick to the same strategy with the same environmental conditions, I can guarantee you 99.999% that you will lose …
Bloody good fun though. See you next time at the black jack table!

By Tim on Jun 18, 2007