Dotenza modelling (with Scratch)


This page is for the school pupils who are using the Dotenza model as part of a science outreach (or engagement) activity. There are teacher (or demonstrator) notes here.

Please note this page, and the teacher notes page, are both currently in draft form.

So what is mathematical modelling, and why do we do it?

Even in primary school you are doing mathematical modelling! This may surprise you, but it’s true. Let me explain.

‘Mathematical modelling’ is a where we use maths to try and understand what is happening now, or to make a prediction about the future. We often use the results of our modelling to make choices.

Perhaps in your lessons you have had to think about the question:

“You go to the shop with £1 to buy 2 apples. Each apple is 30 pence. How much money will you have left after you have paid for the two apples?”

This is an example of modelling. You are using maths (or in this case a topic within maths called arithmetic) to try and make a prediction about the future. This simple sum lets you know before you get to the shop, in fact before you leave the house, whether you can buy the two apples (yes), whether you could buy a third apple (yes), and how much change you will get.

You might have to make choices based on your modelling. Perhaps the person sending you to the shop tells you to buy sweets with change. Your ‘model’ will tell you whether the 40 pence change is enough to buy the sweets you like.

Maths gets a bit more complicated as school goes on: we swap numbers for letters (algebra), then angles (trigonometry), then tables (matrices and vectors) and some where along stuff that only computers can solve. But all these fancy bits of maths are ‘tools’ scientists can use to solve real world problems which end up being (unfortunately) bit more difficult than calculating your change when you go shopping. (Although, it has to be said that working out how much things cost is a vital skill, and took humans several thousand years to work out!)

Mathematical modelling can also be thought as a bit like an experiment that scientists do in a computer. Sometimes scientists want to do experiments that are difficult or expensive and sometimes they want to do experiments that are impossible, because those experiments want to look into a future that hasn’t happened yet. Very few scientists work for a boss who has both huge amounts of money and is a Timelord, so they have to try mathematical modelling.

So, scientists use maths (some of it simple and some of it complex) to try and get a rough idea of how the world works. For example,  when one of the apples you’d bought originally fell off the tree to the ground, the speed it fell at can be estimated using mathematical equations: it won’t be exactly right, but often close enough.

Mathematical modelling of diseases

At the time of writing this blog, everyone in the UK is in isolation because of Covid-19. One of the problems the UK government has is that, because Covid-19 is a brand new disease, it’s not clear how quickly it will spread, how many people will become ill and how many will need serious treatment in intensive care. However, the government needs to ‘see into the future’ so it can plan for more hospital beds, food deliveries and medicines to help people who are sick, vulnerable, or at risk of becoming ill. So scientists have been using mathematical modelling to help governments all over the world plan.

We’re not going to do modelling experiments using Covid-19. At the time we wrote this it was a serious pandemic, and so wasn’t much fun to write blog and computer programs about. So we invented a new harmless disease, called Dotenza.

Welcome to Dot Land.

These are modelling experiments in Dot Land. Dot Land is an island where a million dots live, most of the time they are healthy and happy, but every so often there’s an outbreak of Dotenza. Dotenza is mostly harmless: the Dots change colour for a while and they need so medicine to help them get better. Some years Dotenza is very infectious, and other years not so. Dot scientists very often develop a vaccine for Dotentza, but they also use mathematical models to help the Dot government plan

Dotenza modelling

Dot scientists use a simple programming language called ‘Scratch’ to model the spread of Dotenza. You may have used Scratch in school, so you may be able to work out the programming or code, behind the model. Scratch works through internet browsers, and so you can play with the model on your phone, laptop, or tablet without having to install any other software. The Dotenza modelling screen looks like this (although not all the buttons and boxes are the same for every experiment).

Slide1You’ll need to know what these do before you start your experiment.

The graph in the middle will draw a line with the number of ill Dots on each day as the virus spreads. The graph will re-draw several times (so you might need to be patient!) Using a pen and paper keep a note of the height of the peak (that is the number of ill Dots and the number of days). That way when you change different sliders you can see what the effect on the Dots of Dot Land will be.

The infectivity slider allows you to change how infectious Dotenza is. You can change the slider from 5 to 0.5 at anytime, even while the graph is plotting. Perhaps to start with the infectivity is 5, but after a while the government closes schools (and the infectivity drops to 2), and then perhaps people are asked to stay at home (and the infectivity drops to 1 or 0.8).  You can use this slider to see what difference infectivity makes.

The delay slider doesn’t change the graph, it just changes how fast new parts of the graph are plotted. You can change this during the plotting if you want.

The play/pause button will pause the modelling (although not the re-drawing of the graph). The modelling is ‘paused’ at the start, so you need to click this button to get it to work.

To start the Scratch program, click the green flag. If you want to stop it (at any time) – thats stop it, and not pause – click the red circle.

There are some delays while the graph re-draws itself (because the size of the graph depends on the values you put into the model), but you can tell the modelling is finished because the screens changes to look like this.


Where the two boxes on the top right tell you the position of your mouse pointer. Point to the top of the peak and it will tell you the number of dots ill, and the day on which that peak occurred.

We’ll describe the other sliders and buttons later.

For experiments 1, 2 and 3 open this version of the model.

Experiment 1: Infectivity

The Dot government knows that a new Dotenza virus comes around every few years. Every time it does it has a different infectivity value. Some years Dotenza is not very infective and an infected person only passes it onto 2 other people, so the infectivity value is 2. Some years Dotenza is very infective and an infected person only passes it onto 5 other people, then the infectivity value is 5.

In this experiment see what happens with different infectivity values to the maximum number of Dots who get ill, what day the peak will occur, the total number of dots who get ill and how long the epidemic will last. For this experiment, set the compliance slider to 100 and don’t click the vaccinate button. (And if you do click the vaccinate button by accident, thats not a problem, just repeat the modelling experiment. That’s the beauty of using maths and computers to do this sort of modelling experiment: if you’d done this in real life and accidentally vaccinated a study population that could be dangerous for the people, and very, very expensive!)

Draw a table like this on a piece of paper:

Experiment 1: Infectivity

Infectivity Total number
of dots ill
Max number
of dots ill
Day on which
the peak happens
Day on which the
epidemic stops
Set this to 5
…to 4
…to 3
…to 2
…to 1.5
…to 1.2
…to 1.0

So what will you tell the Dot Land government about how quickly different Dotenza viruses might move though the population. Is there a difference between the number total number of dot who get ill? Can you get why this is?

Extra experiment: you might be wonder what would happen if the infectivity was less than 1. Well you can try this too. Just set the infectivity to ??, click pause when the number of ill dots gets to about 10,000, move the infectivity to 0.6 (or what ever number you want) and click play.

Experiment 2: Compliance

The government has an idea: if there is an epidemic they propose asking people to stay at home to reduce the infectivity to 0.5, but they want to know want might happens if some people ignore them. This is called compliance rates. Set the infectivity to 1, and the compliance to 100, then 90, then 75, and finally 50, and watch what happens to the number of Dots that get ill.

The government are wondering about allowing people to go about their normal lives (with an infectivity of 5) for 20 days, and then asking people to stay at home (to reduce the infectivity to 1) for 20 days, then allowing people to go out again. They want to know if this will control the disease. Set the infectivity slider to 5, the compliance slider to 100, and the delay slider to 0.1. Wait for 20 days on the x-axis and change the infectivity slider to 1 for 20 days (and then repeat). Can the government of Dot Land keep the disease under control that way?

Experiment 2: Vaccination

The government doesn’t have a vaccine for Dotenza when the disease first starts to spread, but wants to know when a vaccine would be most useful and how much of the remaining population needs to be vaccinated. (They wouldn’t vaccinate Dots who had recovered from the virus).

Set the infectivity to about 2 and the virus should peak about 170 days with 160,000 Dots ill and last for around 400 days. What happens if you vaccinate at the 50% and 75% levels after 80 days, and what happens at a 75% level vaccination after 250 days? Where would you vaccinate the population?

Experiment 3: Resistance

The island faces new strain of Dotenza, but a vaccine is available and the government has a change to immunise the population before the virus starts to spread. The government wants to know how this will change the spread of the virus.

Before you click the Play button, set the infectivity to 5, and the compliance to 100. Run the model and record the peak values (number of ill Dots and the number of days).

Do the same again, but set the vaccination level to 50. Click the vaccination button (this is the same has making 50% of the population immune to the virus before the epidemic start). Run the model and record the peak values (number of ill Dots and the number of days).

Do the same again, but set the vaccination level to 65. Click the  the vaccination button. Run the model and record the peak values (number of ill Dots and the number of days).

Do the same again, but set the vaccination level to 75. Click the  the vaccination button. Run the model and record the peak values (number of ill Dots and the number of days).

Do the same again, but set the vaccination level to 80. Click the  the vaccination button. Run the model and record the peak values (number of ill Dots and the number of days). Hint: if nothing happens and no graph is drawn, that is because the virus can’t spread at all.

Experiment 4: Modelling with limits on medicines

The government of Dot land has another problem. DotPharma, the company that makes all the medicines on the island, has told them that they cannot make enough medicine to treat everyone on the island at the same time. For everydot to get their medicine, the number of ill dots must be kept below 50000 (5% of the island’s Dot population). Remember you can change the infectivity at anytime during the plotting.

How are you going to keep the number of ill Dots below 50000?

For experiment 4 open this version of the model. When you get close to 50000 you will see a purple/pink line appear. When you go over the limit the computer will beep at you.

Experiment 4: Diagnosis delays.

Experiment 4 is just like experiment 3, but harder.

It now a takes two weeks (14 days) for the government to see the number of infected Dots. (Because it takes that long for the Dots to become ill, to see the doctor, to get tested and for the tests to come back.) Every time you make a change to the model because of what you se eon scree, it wont have any effect on the numbers of Dots who become sick for another two weeks!

For experiment 4 open this version of the model.

Final thoughts

The statistician George Box supposedly said “All models are wrong, but some are useful.” We hope you found this modelling useful


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s