Martingale simulator

7 min read Original article ↗

A martingale is a kind of betting strategy where you double your wager on every loss such that the first win recovers all previous losses plus a profit equal to the initial wager. It's pretty obvious this doesn't work in practice, but let's visualise it and see if we can learn anything in the process.

A martingale strategy for roulette goes like this:

  • You start by betting 10 on black.
  • If the ball lands on black, you've won 10.
  • If the ball lands on red, you've lost the 10 you bet. So, you bet 20 on black. If you lose, you bet 40. If you win, you've won 40. Subtracting the \(10+20=30\) losses, you're left with a profit of 10.

At first glance, it seems like you eventually make your original wager as profit. This doesn't actually work because you inevitably get a long-enough string of losses that you just don't have the money to double your previous bet.

The simulator

Here is a little Picotron simulation of running a martingale strategy on roulette:

Martingale simulator. Click to start. If you scroll down the page, your browser will probably freeze the simulator—wiggle your mouse inside it and click to resume.

Here are a few things to try:

  • Press "Spin once" a few times to get a feel for what the simulator is doing and what the log entries say.
  • Increase the speed to 40x and press "Keep spinning" to run the simulation until you run out of money. Press "Reset" and "Keep spinning" again to re-run the simulation. The graph shows the gain or loss for every spin.

Observations

There are links to rigorous mathematical analyses of martingale strategies in the references of the Wikipedia page. Here, we're just going to make some general observations about perception and interpretation.

The crash

Some runs are short and you get wiped out after 20 spins and some runs are really long. For example, below is a run that went on for 2,275 spins and got up to 13k cash (up 13x from the initial 1k). At 10 spins/sec, this took 4 minutes to run.

Figure 1. Cash growing through a martingale run of 2,275 spins. The graph gently ascends to about 13,000 before suddenly crashing to -8,000.

I encourage the reader to re-run the simulation a few times to see a long run like this. The psychological effect is uncanny in that you're lulled into a false sense of security even when you know the blow-up is inevitable.

The crash always comes as a shock. It took just 11 bad spins to wipe out 13k of cash. In other words, the crash was just the last 2 seconds of a 4 minute run.

Zero is win/lose/pass

Roulette is not a fair game. A European roulette table has 18 red slots, 18 black slots, and one green slot. So, the probability of the ball landing on black is actually not 50%, but 48.6%. Since a bet on black doubles your wager, the expected value is \(-10 + 20 \times 0.486 = -0.28\). It's negative, so you lose money on every roll on average.

Interestingly, the above is not why the martingale strategy doesn't work. In the simulator, you can click the "Zero is lose" button to change it to "pass" (a green zero is neither a win nor a loss) or to "win" (a green zero is always a win for the player). "Pass" makes the probability of a win 50%. "Win" makes the probability of a win 51.4%. These make the runs a bit longer, but they certainly don't prevent the crash from happening.

Martingale strategies don't fail because the odds are bad. They fail because they're terrible at risk management.

Intuitively, what's happening is that the safety gained from having more money grows slower than the risk needed to get more money in the first place. For example, starting with a bet of 10, it takes 8 bad spins to wipe out a cash pool 1,280. The next level of safety is at 2,560 which requires 9 bad spins to wipe out. But to increase your tolerance from 8 to 9 bad spins, you have to get 128 wins. It then takes another 256 wins to get to the next level. And 512 to the one after. Getting 10 bad spins in a row has a probability of about 1 in 1000. That's pretty unlikely, but if you do 250 spins, it becomes a lot more probable.

Risk and volatility

There's also something to be said about risk and volatility and how they're not the same thing. Consider the below graph:

Figure 2. A graph showing a line going up. It is the same graph as Figure 1, but with the crash cut out.

There is not a lot of volatility here. There was a bit at the start, but it would've gotten washed out of any volatility measure by the almost straight line afterwards. The graph is of course the first one with the crash at the end cut off.

If I saw an investment asset with a price graph like this, I'd assume it was safe like a bond. This is wrong because it conflates volatility and risk. Volatility is a measure of the price fluctuations and it is indeed low. Risk is how likely it is to lose money and for martingale strats, it is high despite the low volatility. For a government bond, the risk is low not because the graph is straight-ish, but because governments don't often default.

I think risk and volatility frequently get conflated because it kind of works for stocks. Stock prices follow random walks and have lognormal distributions, so it is meaningful to talk about standard deviations and how likely price movements of specific magnitudes are. We frequently see stock price charts and form the intuition that jagged lines are risky and straight lines are safe. We can plot other things as charts and the intuition carries over, even when it shouldn't.

Here's another interesting graph:

Figure 3. Cash growing through a modified martingale run of 150 spins. The modification is that the base wager is 5% of available cash instead of a fixed number. The graph goes from 1,000 to 38,000 before crashing to -19,000.

This is the same martingale simulator except that the base bet is 5% of cash instead of a fixed 10. This is even riskier because you're always 5 bad spins away from blowing up. That said, the line goes up much faster. It took normal martingale 2,200 spins to get to 8k, but this modified martingale only needed 150 spins to get to 38k.

The main difference between the normal martingale and the modified one is that the former is linear while the latter is geometric. This matters because most real-world processes are geometric (e.g. an investment portfolio increases by 4% every year and not by some fixed amount).

I've definitely seen graphs like the above in the real world which makes me wonder about the underlying processes driving them.

Conclusion

Martingale is a pretty terrible betting strategy. I think its appeal mostly comes from the feeling of security a long run instills. Still, it's interesting to see it in action and see how reminiscent the graphs are to those of real world financial instruments.

Code

Below is the Picotron cartridge as well as the single-page HTML of the simulator. The PNG itself is the cart and you'll need Picotron to see and edit the code.