If you are a teacher then please also visit my new site: intermathematics.com for over 2000+ pdf pages of resources for teaching IB maths!

The Martingale system

The Martingale system was first used in France in 1700s gambling halls and remains used today in some trading strategies.  I’ll look at some of the mathematical ideas behind this and why it has remained popular over several centuries despite having a long term expected return of zero.

The scenario

You go to a fair ground and play a simple heads-or-tails game.  The probability of heads is 1/2 and tails is also 1/2.  You place a stake of counters on heads.  If you guess correctly you win that number of counters.  If you lose, you double your stake of counters and then the coin is tossed again.  Every time you lose you double up your stake of counters and stop when you finally win.

Infinitely deep pockets model:


You can see that in the example above we always have a 0.5 chance of getting heads on the first go, which gives a profit of 1 counter.  But we also have a 0.5 chance of a profit of 1 counter as long as we keep doubling up our stake, and as long as we do indeed eventually throw heads.  In the example here you can see that the string of losing throws don’t matter [when we win is arbitrary, we could win on the 2nd, 3rd, 4th etc throw].  By doubling up, when you do finally win you wipe out your cumulative losses and end up with a 1 counter profit.

This leads to something of a paradoxical situation, despite only having a 1/2 chance of guessing heads we end up with an expected value of 1 counter profit for every 1 counter that we initially stake in this system.

So what’s happening?  This will always work but it requires that you have access to infinitely deep pockets (to keep your infinite number of counters) and also the assumption that if you keep throwing long enough you will indeed finally get a head (i.e you don’t throw an infinite number of tails!)

Finite pockets model:

Real life intrudes on the infinite pockets model – because in reality there will be a limit to how many counters you have which means you will need to bail out after a given number of tosses.  Even if the probability of this string of tails is very small, the losses if it does occur will be catastrophic –  and so the expected value for this system is still 0.

Finite pockets model capped at 4 tosses:

In the example above we only have a 1/16 chance of losing – but when we do we lose 15 counters.  This gives an expected value of:

Finite pockets model capped at n tosses:

If we start with a 1 counter stake then we can represent the pattern we can see above for E(X) as follows:

Here we use the fact that the losses from n throws are the sum of the first (n-1) powers of 2. We can then notice that both of these are geometric series, and use the relevant formula to give:

Therefore the expected value for the finite pockets model is indeed always still 0.

So why does this system remain popular?

So, given that the real world version of this has an expected value of 0, why has it retained popularity over the past few centuries?  Well, the system will on average return constant linear growth – up until a catastrophic loss.  Let’s say you have 100,000 counters and stake 1 counter initially.  You can afford a total of 16 consecutive losses.  The probability of this is only:

but when you do lose, you’ll lose a total of:

So, the system creates a model that mimics linear growth, but really the small risk of catastrophic loss means that the system still has E(X) = 0.  In the short term you would expect to see the following very simple linear relationship for profit:

With 100,000 counters and a base trading stake of 1 counter, if you made 1000 initial 1 counter trades a day you would expect a return of 1000 counters a day (i.e 1% return on your total counters per day).  However the longer you continue this strategy the more likely you are to see a run of 16 tails – and see all your counters wiped out.

Computer model

I wrote a short Python code to give an idea as to what is happening. Here I started 9 people off with 1000 counters each.  They have a loss limit of 10 consecutive losses.  They made starting stakes of 1 counter each time, and then I recorded how long before they made a loss of 10 tosses in a row.

For anyone interested in the code here it is:

The program returned the following results.  The first number is the number of starting trades until they tossed 10 tails in a row.  The second number was their new account value (given that they had started with 1000 counters, every previous trade had increased their account by 1 counter and that they had then just lost 1023 counters).

1338, 1315
1159, 1136
243, 220
1676, 1653
432, 409
1023, 1000
976, 953
990, 967
60, 37

This was then plotted on Desmos. The red line is the trajectory their accounts were following before their loss.  The horizontal dotted line is at y = 1000 which represents the initial account value.  As you can see 6 people are now on or below their initial starting account value.  You can also see that all these new account values are themselves on a line parallel to the red line but translated vertically down.

From this very simple simulation, we can see that on average a person was left with 884 counters following hitting 10 tails.  i.e below initial starting account.  Running this again with 99 players gave an average of 869.

999 players

I ran this again with 999 players – counting what their account value would be after their first loss.  All players started with 1000 counters.  The results were:

31 players bankrupt: 3%

385 players left with less than half their account value (less than 500): 39%

600 players with less than their original account value (less than 1000): 60%

51 players at least tripled their account (more than 3000): 5%

The top player ended up with 6903 counters after their first loss.

The average account this time was above starting value (1044.68).  You can see clearly that the median is below 1000 – but that a small number of very lucky players at the top end skewed the mean above 1000.

Second iteration

I then ran the simulation again – with players continuing with their current stake.  This would have been slightly off because my model allowed players who were bankrupt from the first round to carry on [in effect being loaned 1 counter to start again].  Nevertheless it now gave:

264 players bankrupt: 26%

453 players left with less than half their account value (less than 500): 45%

573 players with less than their original account value (less than 1000): 57%

95 players at least tripled their account (more than 3000): 10%

The top player ended up with 9583 counters after their second loss.

We can see a dramatic rise in bankruptcies – now over a quarter of all players.  This would suggest the long term trend is towards a majority of players being bankrupted, though the lucky few at the top end may be able to escape this fate.

Essential Resources for IB Teachers

1) Intermathematics.com

Screen Shot 2021-08-21 at 1.07.49 PM

If you are a teacher then please also visit my new site.  This has been designed specifically for teachers of mathematics at international schools.  The content now includes over 2000 pages of pdf content for the entire SL and HL Analysis syllabus and also the SL Applications syllabus.  Some of the content includes:

  1. Original pdf worksheets (with full worked solutions) designed to cover all the syllabus topics.  These make great homework sheets or in class worksheets – and are each designed to last between 40 minutes and 1 hour.
  2. Original Paper 3 investigations (with full worked solutions) to develop investigative techniques and support both the exploration and the Paper 3 examination.
  3. Over 150 pages of Coursework Guides to introduce students to the essentials behind getting an excellent mark on their exploration coursework.
  4. A large number of enrichment activities such as treasure hunts, quizzes, investigations, Desmos explorations, Python coding and more – to engage IB learners in the course.

There is also a lot more.  I think this could save teachers 200+ hours of preparation time in delivering an IB maths course – so it should be well worth exploring!

Essential Resources for both IB teachers and IB students

1) Exploration Guides and Paper 3 Resources

Screen Shot 2021-12-01 at 1.19.14 PM

I’ve put together a 168 page Super Exploration Guide to talk students and teachers through all aspects of producing an excellent coursework submission.  Students always make the same mistakes when doing their coursework – get the inside track from an IB moderator!  I have also made Paper 3 packs for HL Analysis and also Applications students to help prepare for their Paper 3 exams.  The Exploration Guides can be downloaded here and the Paper 3 Questions can be downloaded here.