Contagious Maths, part 2: Play Lucky Dip!

Marianne Freiberger, Julia Gog and Rachel Thomas Share this page

This content is part of our Contagious maths project, and builds on the mathematical model we built in part 1. You can find all the content for Contagious maths here.

Improving our model

How realistic is the model we built in part 1? Let's find out from Julia Gog, a disease modeller at the University of Cambridge.

"When we're making models they don't have to perfectly match up to reality," says Julia. Instead what we want is to capture the general picture with our model, so we've got an idea of the behaviour that is consistent with a real epidemic.

Our previous model started off with 1 infected person, and each infected person would go on to infect two more people. This model, with the reproduction ratio, R=2, was really good at describing the start of an outbreak as the epidemic starts to take off. We start off with 1 infected person, who infects 2 people, who infect 2x2=22=4 people, who infect 2x2x2=23=8 people, and so on. But if we keep doubling the number of people infected in each round, or generation, of the epidemic, something odd will happen.

In the 10th generation over a thousand people will be infected, in the 20th generation over a million people will be infected and in the 30th generation over a billion will be infected. Things get quickly out of hand and the model will give the size of the epidemic to be larger than our community, than our country, and sooner or later, larger than the total population of the planet! "It's going to continue to grow without any limits at all and that's clearly bonkers!" says Julia.

But rather than abandoning a model, Julia and her colleagues think about how they can adapt or extend the model in some way. For our model we've got to think about what happens later on in the epidemic. "The odd thing in our model was assuming that each person can definitely go out there and find two new people to infect." Maybe it's ok to assume someone can encounter two more people, but these people may have had the disease in the past. There aren't infinitely many new people to infect.

This process of experimentation and adaption is a good illustration of the experience of researchers applying maths to science. "Things are no longer black and white – it's a more exploratory way of working," says Julia. "We remain open to changing and reviewing our ideas."

Play Lucky Dip!

In order to make the model we built in Part 1 more realistic, Julia and Plus Editor Rachel Thomas play a game of Lucky Dip (with thanks to Dan Plane and the team at the Royal Institution for the capsules and custom-made tokens.)

In this game of Lucky Dip we have a box of identical capsules, each with a red token inside. Each capsule represents a person in our population, so we have 26 capsules meaning we have a population of 26 people.

Just like in our first model we start off with one infected person. So we give the population a good mix and pick a capsule from the box, representing the first person to be infected. "There's our very first case," says Julia. To keep track of the people infected we take the red token out of the capsule and put it up on the board, one column of red tokens for each generation of infections. "We're going to build this over time and that's our first generation: one case."

Much as in our previous model, we have each infected person going on to infect 2 others from our population. "But [here] is the new bit of the model," says Julia. "We're going to pick them from our fixed population." So we put the empty capsule of the person who was case 1 back into the population, give the population a good mix, and pick two capsules from the population of 26. We put their red tokens up on the board in a column to represent the new infections in the second generation and return the empty capsules back into the population ready for the next round of infection.

In the video, we had 1 person infected in the first generation, 2 in the second generation and 4 in the third generation. But something interesting happens when we were picking 8 capsules to represent 8 people being infected in the fourth generation. "Some of these have red tokens, and some are empty," says Julia. "So something new has happened in our model."

What do you think these empty capsules mean in terms of the people they represent? What is it representing in our model of the epidemic? And how should we continue to run our model from here?

A new rule for our model

Here's Julia's idea for how we can think about an empty capsule.

When we started running this epidemic all the capsules, each representing a person in our population, started with a red token inside. "If [the capsule we've picked is] empty, it means it must have been one of the ones we picked out earlier in the epidemic," says Julia. "It means it was a person who has previously been infected."

We need to make a decision of how to handle this situation in our model. One option is to assume that that once you've had the disease you can get infected again, or that you can get infected again but that this is much less likely once you've had it once. But the assumption we are going to use for our updated model is that once you have had the disease, you recover and are immune, and you don't get it again.

So a previously infected person can't be infected again, and so they can't infect anyone else in this generation. The four empty capsules we had picked go straight back into the population and they can't add any new infections to the next round. Whereas the four capsules we picked out with red tokens do get infected – so their red tokens go onto the board in a column for the fourth generation.

In this video there have been 1, 2, 4 and 4 infections in the four generations of the epidemic we've run so far. "So we've already broken out of these powers of 2 that we were getting before," says Julia.

We have 4 infections in the fourth generation of this video, so once all the emptied capsules are back in and the population is mixed, we pick 8 capsules for the next generation of infection (2 for each of the 4 people infected in this generation). "At this point we've actually got all the rules we need to go ahead and run the epidemic," says Julia.

Have a go yourself!

Now that we have resolved the question about empty capsules, how do you think the game of Lucky Dip will continue? To find out, you can have a go yourself with the Lucky Dip interactivity below, created by our friend, Oscar Gillespie, from NRICH.

The interactivity works like our game of Lucky Dip. Each person is represented by a capsule which is drawn at random. The default setting is R=2.

Begin by clicking 'Run one generation'. You can watch the jumbler working, or click "Next" to skip the animation.

The jumbler will release a single capsule with a red token, which represents a single infected person. The screen will now indicate that there will be '2 infected' in the next generation.

When you click 'Next', you will have a choice:

  • Click 'Run one generation' again, to see what happens in the next generation
  • Click 'Run to the end', to see a chart showing the number of infections in each generation

The role of immunity

Now you've had a chance to play Lucky Dip yourself, here are Julia and Rachel again, finishing off their own game of Lucky Dip.

When we ran our epidemic model in this video we ended up the following number of new cases in each generation:

1, 2, 4, 4, 6, 5, 2, 0

The number of new cases in each generation started off as powers of 2, just as it did in our previous model from part 1, but then something different happened in the fourth generation. We had a peak of 6 new infections in the fifth generation. And then the number of new cases came down quite abruptly as we were picking out quite a lot of empty capsules towards the end.

Why did our epidemic end? We didn't run out of people to infect as there were still two capsules left that still had their red tokens. "They were in the bag the whole time, they just happened not to have been picked," says Julia. "There's nothing special about them, they're just jolly lucky!"

As we picked more empty capsules towards the end of our simulation, the epidemic turned over because of the immunity in the population. "The epidemic had its breaks put on," says Julia. Those uninfected in the population were protected by those who had already been infected and were now immune, something disease modellers call herd immunity. (You can read more about R and its link to herd immunity.)

"That's our simulation complete, or at least one run of it," says Julia. "What would happen if we reset and run it again?"


If you have used the Lucky Dip interactivity to run simulations of epidemics a few times, you might have started to see differences and similarities between different runs.

In this video we ran the simulation four more times to get epidemics with the following numbers of new cases in subsequent generations:

1, 2, 4, 7, 7, 3, 0

1, 2, 3, 3, 4, 2, 2, 2, 0

1, 2, 4, 6, 5, 5, 0

1, 2, 4, 6, 4, 3, 2, 1, 0

We get different outcomes because the Lucky Dip game has an element of randomness, through picking out random capsules for each generation of new infections. And while each simulation of an epidemic might have a slightly different outcome, there are things they will have in common.

"If you look between different runs you'll usually see these same features," says Julia. You get this initial pattern of takeoff and acceleration, you'll usually get some sort of peak and turn over, and usually some sort of tailing off at the end. "Some things will vary between runs, for example the height of the peak or the whole length of the epidemic, however, overall you tend to get a classic epidemic shape coming out no matter what you do."

You might find it interesting to compare the shapes you are getting from your simulations of epidemics with data for real epidemics. What features do they have in common and how are they different?

Congratulations on your new mathematical model!

Tadaaa! With all this game playing we have actually built and run another mathematical model! This one is very similar to the kind of model real disease modellers use all the time, as Julia explains.

"This [model] is actually really close to the types of models that we use in research," says Julia. The type of model Julia and her colleagues often use is the SIR model, where S stands for susceptive, I stands for infected, and R stands for recovered. (You can read more in Maths in a minute: The SIR model.)

"This model forms the basis of pretty much everything we do in infectious diseases research where we are using mathematical modelling." The model is very flexible and it has all the key components, including that recovering with immunity leads to the epidemic turning over.

"You've also seen that we don't need our models to be the same as reality for them to be valuable," says Julia. The model we've been exploring has already given us good insights into how herd immunity works. Yet the model still isn't right. The idea that each infected person goes on to expose exactly two people to the infection is weirdly specific. "You know life is not like that. Life is a lot more complicated in how we mix and interact."

Still, although the details may not be exactly right, something about this model has really captured the essence of how an epidemic takes off and turns over. But we can go further still. What else is the model missing? Rather than think about every possible details, what are the things that really matter? What factors are we missing that might be important for how epidemics work?

Click here to explore how we can extend our model further in Part 3 of Contagious Maths.

These Contagious Maths resources were developed and written by Julia Gog and the MMP team, including both NRICH and Plus, and funded by the Royal Society’s Rosalind Franklin Award 2020. We have tailored these resources for ages 11-14 on NRICH, and for older students and wider audiences on Plus.