Milan Sanremo in a Random Forest

Last time I tried to predict a race, I trained up a neural network on past race results, ahead of the World Championships in Harrogate. The model backed Sam Bennett, but it did not take account of the weather conditions, which turned out to be terrible. Fortunately the forecast looks good for tomorrow’s Milan Sanremo.

This time I have tried using a Random Forest, based on the results of the UCI races that took place in 2020 and so far in 2021. The model took account of each rider’s past results, team, height and weight, together with key statistics about each race, including date, distance, average speed and type of parcours.

One of the nice things about this type of model is that it is possible to see how the factors contribute to the overall predictions. The following waterfall chart explains why the model uncontroversially has Wout van Aert as the favourite.

Breakdown of prediction for Wout van Aert

The largest positive contribution comes from being Wout van Aert. This is because he has a lot of good results. His height and weight favour Milan Sanremo. He also has a strong positive coming from his team. This distance and race type make further positive contributions.

We can contrast this with the model’s prediction for Mathieu van der Poel, who is ranked 9th.

Breakdown of prediction for Mathieu van der Poel

We see a positive personal contribution from being van der Poel, but having raced fewer UCI events, he has less of a strong set of results than van Aert. According to the model the Alpecin Fenix team contribution is not a strong as Jumbo Visma, but the long distance of the race works in favour of the Dutchman. The day of year gives a small negative contribution, suggesting that his road results have been stronger later in the year, but this could be due to last year’s unusual timing of races.

Each of the other riders in the model’s top 10 is in with a shout.

It’s taken me all afternoon to set up this model, so this is just a short post.

Post race comment

Where was Jasper Stuyven?

Like Mads Pedersen in Harrogate back in 2019, Jasper Stuyven was this year’s surprise winner in Sanremo. So what had the model expected for him? Scrolling down the list of predictions, Stuyven was ranked 39th.

Breakdown of prediction for Jasper Stuyven

His individual rider prediction was negative, perhaps because he has not had many good results so far this year, though he did win Omloop Het Nieuwsblad last year and had several top 10 finishes. The model assessed that his greatest advantage came from the length of the race, suggesting that he tends to do well over greater distances.

The nice thing about this approach is that that it identifies factors that are relevant to particular riders, in a quantitative fashion. This helps to overcome personal biases and the human tendency to overweight and project forward what has happened most recently.

Hexagons in the Arctic Circle

An attractive aspect of hexagonal patterns is that they can repeat in interesting ways across a cycling jersey. This is partly due to the fact that a hexagon can be divided up into three equal lozenge shapes, as seen near the neck of the top right jersey. These shapes can be combined in imaginative ways, as displayed in the lower two examples.

This three-way division of a hexagon can create a 3D optical illusion called a “Necker cube”, which can appear to flip from convex to concave and back again. The orange patch can appear to be the top of a cube viewed from above or the ceiling in a corner, viewed from below. See if this happens if you stare at the image below.

Looking down on a cube or up into the corner of a room?

Spoiler alert: from here things gets a bit mathematical


A tessellation, or tiling, is a way of covering a plane with polygons of various types. Tessellations have many interesting mathematical properties relating to their symmetries. It turns out that there are exactly 17 types of periodic patterns. Roger Penrose, who was awarded the 2020 Nobel Prize in Physics for his work on the formation of black holes, discovered many interesting aperiodic tilings, such as the Penrose tiling.

While some people were munching on mince pies before Christmas, I watched a thought-provoking video on a related topic, released by the Mathologer, Burkard Polster. He begins by discussing ways of tiling various shapes with dominoes and goes on describe something called the Arctic Circle Theorem. Around the middle of the video, he shifts to tiling hexagon shapes with lozenges, resulting in images with the weird 3D flipping effect described above. This prompted me to spend rather a lot of time writing Python code to explore this topic.

After much experimentation, I created some code that would generate random tilings by stochastically flipping hexagons. Colouring the lozenges according to their orientation resulted in some really interesting 3D effects.

Algorithm flips a random hexagon to create a new tiling.


The video shows random tilings of a hexagonal area. These end up looking like a collection of 3D towers with orange tops. But if you focus on a particular cube and tilt your screen backwards, the whole image can flip, Necker-style into an inverted version where the floor becomes the ceiling and the orange segments push downwards.

I used my code to create random tilings of much bigger hexagons. It turned out that plotting the image on every iteration was taking a ridiculous amount of time. Suspending plotting until the end resulted in the code running 10,000 time faster! This allowed me to run 50 million iterations for a hexagon with 32 lozenges on each size, resulting in the fabled Arctic Circle promised by the eponymous theorem. The central area is chaotic, but the colours freeze into opposite solid patches of orange, blue and grey outside the circumference of a large inscribed circle.

Arctic Circle emerged on a hexagon of side 32 after 50 million iterations

Why does the Arctic Circle emerge?

There are two intuitive ways to understand why this happens. Firstly, if you consider the pattern as representing towers with orange tops, then every tower must be taller than the three towers in front of it. So if you try to add or remove a brick randomly, the towers at the back are more likely to become taller, while those near the front tend to become shorter.

Two examples of paths from left to right

The second way to think about it is that, if you look carefully, there is a unique path from each of the lozenges on the left hand vertical side to the corresponding lozenge on the right hand vertical side. At every step, each path either goes up (blue) or down (grey). The gaps between the various paths are orange. Each step of the algorithm flips between up-down and down-up steps on a particular path. On the large hexagon, the only way to prevent the topmost cell from being orange is for the highest path to go up (and remain blue) 32 times in a row. This is very unlikely when flips are random, though it can happen more often on a smaller size-6 hexagon like the one shown in the example.


A Jupyter notebook demonstrating the approach and Python code for running longer simulations are available on this GitHub page.

Back to cycling jerseys

The Dutch company DSM is proudly sponsoring a professional cycling team in 2021. And a hexagon lies at the heart of the DSM logo, that will appear on the team jerseys.

Science for dance performance

Professional dancers are like elite athletes

This web site is about using science to improve performance. Although my focus has generally been on sport, science can also help artistic performance. Professional dancers face many of the same challenges as elite athletes, but a cultural divide separates the two communities. A recent paper helps to bridge this gap, by showing that scientific advances in managing relative energy deficiency in sport (RED-S) may be of great benefit in the dance world.

Dance and sport

Professional dancers spend many hours a day training in order to deliver top level performances in high pressure situations. On stage, they are quite literally under the spotlight. They also start young, developing bodies that are able to meet the high level of technical demands required to reach the top. In spite of the similarities with the lives of those in elite sport, artistic performance is viewed differently from athletic performance. A prima ballerina would not consider herself an athlete any more than a sprinter would consider herself a dancer. Strictly Ballroom is dance, whereas figure skating is sport. This separations stretches from the individual participants up to the level of governing bodies.

Athletes in many sports adapt their body composition to gain an advantage, often seeking to achieve “race weight” ahead of competition. In many ways, the situation is more extreme for dancers, particularly those pursuing classic forms such as ballet, who aim for a body shape that meets aesthetic ideals, while maintaining the strength and flexibility to perform.

Relative energy deficiency in dance

In the paper, dancers were invited to complete an online survey that had been based on previous studies of athletes who were potentially at risk of low energy availability, specifically RED-S. Responses included anthropomorphic data, training and performance hours, injuries and illness, indicators of hormone status and attitudes to eating and weight control.

A RED-S risk score was derived from each dancer’s responses. Of the 247 participants, 57% of females and 29% of males had negative scores, consistent with low energy availability.

Psychological factors proved to be important. Many dancers felt anxious about missing class or rehearsals, in a similar way to athletes who suffer from exercise addiction. These dancers also tended to be more obsessive about controlling their weight and what they eat. Most considered the chances of gaining a leading role to be higher if they lost weight. These kinds of attitudes were observed in an earlier study of male cyclists.

Among the female dancers, some interesting correlations showed up between these mental attitudes and both physical and physiological factors. The more obsessive individuals tended to have a lower body mass index (BMI) particularly when calculated using their lowest weight for their current height. They also tended to have experienced various forms of menstrual disfunction, indicating a disruption to normal hormonal function that has been observed in female athletes in low energy availability.

The large majority of dancers had not heard of Relative Energy Deficiency in Sport, probably because they do not self-identify as sportsmen/sportswomen. Yet the peer pressure of dance schools and dance companies, combined with ever present social media, can lead some dancers to restrict energy intake to levels that are insufficient to meet the high demands of training and performance.

Fit to dance

The authors hope that the publication of this study will help raise awareness in the dance community of the importance of fuelling for the work required. The fact that physical outcomes are connected, via hormones, to mental attitudes is particularly relevant during the COVD crisis, which has impacted the dance world in such a tragic way. The hope is that dancers will be fully fit and healthy to return to the stage, when the theatres eventually open.


Indicators and correlates of low energy availability in male and female dancers
Nicola Keay, AusDancers Overseas, Gavin Francis

Energy Availability: Concept, Control and Consequences in relative energy deficiency in sport (RED-S)

Low energy availability assessed by a sport-specific questionnaire and clinical interview indicative of bone health, endocrine profile and cycling performance in competitive male cyclists, Nicola Keay, Gavin Francis, Karen Hind

Pro cycling team networks

The COVID-19 pandemic has further exposed the weakness of the professional cycling business model. The competition between the teams for funding from a limited number of sponsors undermines the stability of the profession. With marketing budgets under strain, more teams are likely to face difficulties, in spite of the great advertising and publicity that the sport provides. Douglas Ryder is fighting an uphill struggle trying to keep his team alive after the withdrawal of NTT as a lead sponsor. One aspect of stability is financial, but another measure is the level of transfers between teams.

The composition of some teams is more stable than others. This is illustrated by analysing the history of riders’ careers, which is available on ProCyclingStats. The following chart is a network of the transfers between teams in the last year, where the yellow nodes are 2020 teams and the purple ones are 2019. The width of the edges indicates how many riders transferred between the teams, with the thick green lines representing the bulk of the riders who stuck with the same team. The blue labels give the initials of the official name of each team, such as M-S (Mitchelton-Scott), MT (Movistar Team), T-S (Trek-Segafredo) and TS (Team Sunweb). Riders who switched teams are labelled in red.

Although there is a Dutch/German grouping on the lower right, the main structure is from the outside towards the centre of the network.

The spikes around the end of the chart show riders like Geoffrey Soupe or Rubén Fernández, who stepped down to smaller non World Tour teams like Team Total Direct Energie (TTDE), Nippo Delko One Provence (NNDP), Euskaltel-Euskadi (E-E), Androni Giocattoli-Sidermec (AG-S ) or U-XPCT (Uno-X Pro Cycling Team).

The two World Tour outliers were Mitchelton-Scott (M-S) and Groupama FDJ (GF), who retained virtually all their riders from 2019. Moving closer in, a group of teams lies around the edge of the central mass, where a few transfers occurred. Moving anti-clockwise we see CCC Team (CT), Astana Pro Team (APT), Trek-Segafredo (T-S), AG2R Le Mondial (ALM), Circus-Wanty Gobert (C-WG), Team Jumbo Visma (TJV), Bora-Hansgrohe (B-H) and EF Pro Cycling (EPC).

Deeper in the mêlée, Ineos (TI_19/IG_20), Deceuninck – Quick Step (D-QS), UAE-Team Emirates (U-TE), Lotto Soudal (LS), Bahrain – McLaren (B-H) and Movistar Team(MT) exchanged a number of riders.

Right in the centre Israel Start-Up Nation (IS-UN) grabbed a whole lot of riders, including 7 from Team Arkéa Samsic (TAS). Meanwhile likes of Victor Campenaerts and Domenico Pozzovivo are probably regretting joining NTT Pro Cycling (TDD_19/NPC_20).

Looking forward

A few of the top riders have contracts for next year showing up on ProCyclingStats. So far 2020/2021 looks like the network below. Many riders are renewing with their existing teams, indicated by the broad green lines. But some big names are changing teams, including Chris Froome, Richie Porte, Laurens De Plus, Sam Oomen, Romain Bardet and Wilco Keldeman, Bob Jungels and Lilian Calmejane.

What about networks of riders?

My original thought when starting this analysis was that over their careers, certain riders must have been team mates with most of the riders in today’s peloton, so who is the most connected? Unfortunately this turned out to be ridiculously complicated, as shown in the image below, where nodes are riders with links if they were ever teammates and the colours represent the current teams. The highest ranked rider in each team is shown in red.

It is hard to make much sense of this, other than to note that those with shorter careers in the same team are near the edge and that Philippe Gilbert is close to the centre. Out of interest, the rider around 9 o’clock linking Bora and Jumbo Visma is Christoph Pfingsten, who moved this year. At least we can conclude that professional cyclists are well-connected.

Lord of the (cycling) rings

Which Lord of the Rings characters do they look like? Ask an AI.

After building an app that uses deep learning to recognise Lord of the Rings characters, I had a bit of fun feeding in pictures of professional cyclists. This blog explains how the app works. If you just want to try it out yourself, you can find it here, but note that may need to be fairly patient, because it can take up to 5 minutes to fire up for the first time… it does start eventually.

Identifying wizards, hobbits and elves

The code that performs this task was based on the latest version of the excellent course Practical Deep Learning for Coders. If you have done bit of programming in Python, you can build something like this yourself after just a few lessons.

The course sets out to defy some myths about deep learning. You don’t need to have a PhD in computer science – the fastai library is brilliantly designed and easy to use. Python is the language of choice for much of data science and the course runs in Jupyter notebooks.

You don’t need petabytes of data – I used fewer than 150 sample images of each character, downloaded using the Bing Image Search API. It is also straightforward to download publicly available neural networks within the fastai framework. These have been pre-trained to recognise a broad range of objects. Then it is relatively quick to fine-tune the parameters to achieve a specific task, such as recognising about 20 different Tolkien characters.

You don’t need expensive resources to build your models – I trained my neural network in just a few minutes, using a free GPU available on Google’s Colaboratory platform. After transferring the essential files to a github repository, I deployed the app at no cost, using Binder.

Thanks to the guidance provided by fastai, the whole process was quick and straightforward to do. In fact, by far the most time consuming task was cleaning up the data set of downloaded images. But there was a trick for doing this. First you train your network on whatever images come up in an initial search, until it achieves a reasonable degree of accuracy. Then take a look at the images that the model finds the most difficult to classify. I found that these tended to be pictures of lego figures or cartoon images. With the help of a fastai tool, it was simple to remove irrelevant images from the training and validation sets.

After a couple of iterations, I had a clean dataset and a great model, giving about 70% accuracy, which as good enough my purposes. Some examples are shown in the left column at the top of this blog.

The model’s performance was remarkably similar to my own. While Gollum is easy to identify, the wizard Saruman can be mistaken for Gandalf, Boromir looks a bit like Faramir and the hobbits Pippin and Merry can be confused.

Applications outside Middle Earth

One of the important limits of these types of image recognition models is that even if they work well in the domain in which they have been trained, they cannot be expected do a good job on totally different images. Nevertheless, I thought it would be amusing to supply the pictures of professional cyclists, particularly given the current vogue for growing facial hair.

My model was 87% sure that Peter Sagan was Boromir, but only 81.5% confident in the picture of Sean Bean. It was even more certain that Daniel Oss played the role of Faramir. Geraint Thomas was predicted to be Frodo Baggins, but with much lower confidence. I wondered for a while with Tadej Pogacar should be Legolas, but perhaps the model interpreted his outstretched arms as those of an archer.

I hoped that a heavily bearded Bradley Wiggins might come out as Gimli, but that did not not seem to work. Nevertheless it was entertaining to upload photographs of friends and family. With apologies for any waiting times to get to it running, you can try it here.

In earlier blogs, I have described similar models to identify common flowers or different types of bike.

Tour de France and COVID-19

A report in VeloNews on the eve of the Tour de France stated that the French government had insisted that the “two strikes and you are out” policy must be enforced by the ASO. This means that if two positive COVID-19 test arise within a team or its support staff, the team will be removed from the race. This raises the possibility of the yellow jersey rider being ejected from the race if, for example, two mechanics record positive tests. This would be particularly unjust if it turns out that a test result was a false positive. So what are the chances that this might happen?

False positives

One of the great frustrations of the reporting on COVID testing has been the lack of clarity about what type of testing is being discussed. Tests fall in to two categories. Antigen tests use a sample from a nasal or pharyngeal swab to detect patients who currently have the disease, whereas antibody tests use a blood sample to identify patients who have developed antibodies as a result of exposure to the disease in the past – more than 28 days earlier.

There are two general types of antigen test. Real time polymerase chain reaction (RT-PCR) tests looks for specific viral fragments and need to be conducted in a laboratory, typically requiring at least 24 hours for a result. Less reliable rapid tests look for proteins associated with the COVID-19 virus, producing results in as little as 15 minutes.

The UCI requires riders and staff to be tested using RT-PCR, which is a very reliable method, having both high sensitivity (ability to detect those with the disease) and high specificity (ability to clear those without the disease). The relevant question for the Tour de France is the probability of a false positive RT-PRC test. Indeed Larry Warbass recently said he thought his result was a false positive, as he had experienced no symptoms and had maintained strict self isolation during training.

The evidence indicates that the machines performing the RT-PRC test are extremely unlikely to generate a false positive, because the test needs to find significant levels of three different targets to confirm the presence of COVID-19. In FDA experiments, 100% of negatives where correctly identified – there were no false positives. However, it remains possible that, in the moving circus of the Tour de France, a sample could become contaminated before it is tested or that samples might somehow be mislabelled. A high level of responsibility falls on the shoulders of team doctors to minimise these risks, but we can never be sure that it is zero.

One in a thousand

As a thought experiment, suppose that a negative RT-PCR test is 99.9% reliable, i.e. that one COVID-free person in a thousand somehow produces a false positive result. What is the chance that a team is unjustly sent home from the Tour?

Each team has eight riders plus support staff. Although teams might want to reduce the number of staff in the team bubble, it may be necessary to have extra catering staff in order to remain self sufficient. Let us assume an average of 17 staff on each of the 21 teams and that everybody has passed the required two negative tests prior to the start of the race. Assume further that nobody contracts COVID-19 throughout the race.

It has been indicated that everyone will be tested on the two rest days. Reassuringly, the probability of two or more false positives in a single team bubble of 25 people would be 0.03% (1-0.999^(25*2)). However, the probability that every team rider receives a negative result would be only 85% (0.999^168), meaning that there would be a 15% chance that at least one rider is unjustly ejected from the race. In fact, since at total of 1,050 tests would be taken by everyone in a team bubble, the chance of at least one person receiving a false positive would be surprisingly high: 65% (1- 0.999^1050).

Perhaps the assumption of 1 in a thousand false positives was a bit alarmist. Reducing it to 1 in thousand still produces a probability of 10% that somebody would be sent home during the Tour.

Blind eyes

In some situations, draconian sanctions might deter team members or staff from reporting symptoms. One could imagine a soigneur or mechanic having to go home quietly after mysteriously spraining a wrist. However, this could create very negative press coverage if word got out that this person was infected.

Furthermore, the UCI rules place responsibility on the teams and specifically the team doctors to apply strict daily monitoring and controls to detect suspected COVID-19 cases.

Champs Elysées

While in the above scenarios no one actually contracted COVID-19, there is, of course a not inconsiderable chance that one of the 525 people in the team bubbles does actually become infected. If the virus spreads to more than one team, the whole race could become a fiasco.

But let’s keep our fingers crossed and hope Tour makes it to the Champs Elysées.

Evenepoel and a fractured pelvis

My hip – post operation

It was shocking to see footage of Remco Evenepoel’s horrific crash in Il Lombardia. Reports indicate that he broke his pelvis after falling from a bridge into a ravine. This follows the injuries sustained by his Deceuninck-QuickStep team mate Fabio Jakobsen in the Tour of Poland.

The video above shows the repairs to my pelvis carried out by the specialist team at St George’s Hospital. My accident was less spectacular than Remco’s, I just hit a large pothole, while riding in the Kent lanes last March. It took the ambulance two and a half hours to arrive, as this was just at the beginning of the COVID-19 crisis. In fact, lock-down was announced on the evening of my crash. There was a lot of uncertainty about the virus back then, so it was a pretty scary time to be in hospital. Nevertheless I have immense respect and gratitude for the NHS staff who looked after me.

I was given crutches the day after the operation and returned home the day after that, with strict instructions to remain non-weight-bearing on the injured leg for six weeks and then only partial weight-bearing for the next six weeks. An NHS physiotherapist contacted me and regularly provided a progression of exercises. I set myself additional challenges, like doing extra press-ups.

After six weeks of doing no proper exercise, I had lost 4kg. The circumference of my left thigh was 5cm less than the right. However, following a review at the hospital, I was given permission to start gentle exercise on my static turbo trainer. I began by removing the left pedal and performing single leg drills, but after a couple of days it was easier to put my injured leg on the pedal as a passenger. This also gave the hip some mobility.

After a week on the turbo, I was up to one hour a day at about 160 watts. It took a long time to increase this above 200 watts. I watched a lot of old cycling films, without any particular urge to go on Zwift. I started riding outside in mid-June, 12 weeks post op. My Garmin pedals allowed me to monitor the left-right balance as well as average power.The following chart shows that 21 weeks after my accident, balance is hovering around 48:52 and five minute power is back over 300 watts.

Left/Right Balance and 5 minute Peak Power, since crash date

The psychological aspect of rehabilitation has been very important. I have focussed on targets and deadlines, marking each little achievement as a milestone. I am now walking without a limp, though running is still off limits. I even went kitesurfing a couple of weeks ago (don’t tell my surgeon about that one). I have been busy learning Italian, composing music and programming in Python.

Since heading back out on the roads, I have been riding cautiously, as my hip will not regain full strength until next spring. I plan to enter a couple of time trials to rekindle a sense of competition, without the danger of riding in a peloton. Racing again next season remains a goal.

Probably the most important mental aspect has been to stay positive at all times and never to spend time feeling sorry for oneself. This has been difficult as, inevitably, there have been a couple of set-backs when progress has seemed to reverse. But on the whole, my recovery has been astounding and, like Chris Froome, I remain optimistic about regaining my peak.

Remco will be back on the road next season, with the potential to pick up some results later in the year.

Efficient COVID testing on a hypercube

A strategy for finding people infected with SARS-CoV-2: optimizing pooled testing at low prevalence, Mutesa et al

In previous blogs, I described how mathematical modelling can help understand the spread of the COVID-19 epidemics and provide privacy-preserving contact tracing. Looking forward at how the world will have to deal with COVID-19 in the coming months, it is likely that a significant percentage of the population will need to be tested multiple times. In a recent BBC science podcast, Neil Turok, Leon Mutesa and Wilfred Ndifo describe their highly efficient method of implementing large-scale testing that takes advantage of pooling samples. This is helping African governments save millions on the cost of testing. I offer an outline of their innovative approach, which is described in more detail in a paper published on

The need for large-scale testing

The roll-out of antigen testing in some countries, like the US and the UK, has been painfully slow. Some suggest that the US may need to carry out between 400,00 and 900,000 tests a day in order to get a grip on the epidemic. When antigen tests cost 30-50 US dollars (or 24-40 UK pounds), this could be very expensive. However, as long as a relatively small percentage of the population is infected, running a separate test for everyone would be extremely inefficient compared with approaches that pool samples.

Pooling offers a huge advantage, because a negative test for a pooled sample of 100 swabs, would clear 100 people with a single test. The optimal size of the pools depends on the level of incidence of the disease: larger pools can be used for lower incidence.

The concept of pooling dates back to the work of Dorfman in 1943. His method was to choose an optimal pool size and perform a test on each pooled sample. A negative result for a pool clears all the samples contained in it. Then the infected individuals are found by testing every sample in the the positive pools. Mutesa and Ndifo’s hypercube method is more efficient, because, rather than testing everyone in an infected pool, you test carefully-selected sub-pools.

The idea is to imagine that all the samples in a pool lie on a multidimensional lattice in the form of a hypercube. It turns out that the optimal number of points in each direction is 3. Obviously it is hard to visualise high dimensions, but in 3-D, you have 27 samples arranged on a 3x3x3 grid forming a cube. The trick to identifying individual infected samples is to create sub-pools by taking slices through the lattice. In the diagram above, there are 3 red slices, 3 green and 3 blue, each containing 9 samples.

Consider, for simplicity, only one infected person out of the 27. Testing the 9 pools represented by the coloured slices will result in exactly 3 positive results, representing the intersection of the three planes passing through the infected sample. This uniquely identifies the positive individual with just 9 tests, whereas Dorfman would have set out to test all 27, finding the positive, on average after doing half of these.

Slicing a hypercube

Although you can optimise the pool size to ensure that the expected number of positives in any pool is manageable, in practice you won’t know how many infected samples are contained in any particular pool. The hypercube method deals with this by noting that a slice through a D-dimensional hypercube is itself a hypercube of dimension D-1, so the method can be applied recursively.

The other big advantage is that the approach is massively parallel, allowing positives to be identified quickly, relative to the speed of spread of the pandemic. About 3 rounds of PCR tests can be completed in a day. Algorithms that further reduce the total number of tests towards the information theoretical limit, such as binary search, require tests to be performed sequentially, which takes longer than doing more tests in parallel.

In order to make sure I really understood what is going on, I wrote some Python code to implement and validate the hypercube algorithm. In principle, it was extremely simple, but dealing with low probability edge cases, where multiple positive samples happen to fall into the same slice turned out to be a bit messy. However, in simulations, all infected samples were identified with no false positives nor false negatives. The number of tests was very much in line with the theoretical value.

Huge cost savings

My Python program estimates the cost savings of implementing the hypercube algorithm versus testing every sample individually. The bottom line is that the if the US government needed to test 900,000 people and the background level of infection is 1%, the algorithm would find all infected individuals with around 110,000 tests or 12% of the total samples. At $40 a test, this would be a cost saving of over $30million per day versus testing everyone individually. Equivalent calculations for the UK government to test 200,000 people would offer savings of around £5million pounds a day.

It is great to see leading edge science being developed in Africa. Cost conscious governments, for example in Rwanda, are implementing the strategy. Western governments lag behind, delayed by anecdotal comments from UK officials who worry that the approach is “too mathematical”, as if this is somehow a vice rather than a virtue.


A strategy for finding people infected with SARS-CoV-2:optimizing pooled testing at low prevalence, Mutesa et al

Cycling at the speed of light

Suppose you are in a Zwift race that comes down to a sprint finish. How long does it take for your avatar to respond to your heroic effort in the final dash for the line? Could a time lag cost you the race?

Consider the steps involved. First the ANT+ signal travels from your power meter to your device (i.e. computer or phone) then it goes to your router and on to Zwift’s server somewhere on the cloud. At some point your watts per kilo are converted into a velocity, taking account of your previous speed, the gradient, rolling resistance, drafting and any PowerUps in play. This calculation can be performed pretty much instantaneously compared with signal transmission time.

The ANT+ signal travels at the speed of light to your device, which is likely to be very close by, so there is little to be gained as long as there is a clear line of sight. The next step, to the router, can be slower, especially if you are relying on a wireless signal from your garage, while running a raft of other applications on your device (best to shut these down). Serious e-gamers often use a direct wired link to the router. It also helps if you have a super-fast high bandwidth internet connection. However, the time taken for the signal to travel from your router to Zwift’s gaming server, called latency, typically introduces the longest delay, especially if it has to go halfway around the world.

We don’t know the precise location of Zwift’s server, but let’s suppose it is in San Francisco. You can check the latency from your location to other parts of the world on web sites like this one. When I looked, the latency from London to San Francisco was 136ms (milliseconds) and from Cape Town it was 281ms.

In the past, banks have moved their trading desks as close as possible to exchanges, in order to obtain prices nanoseconds earlier than their rivals. As a general rule for interactive online gaming, you need a latency of less than 100ms for acceptable gameplay and over 150ms can become frustrating. But we are not talking about playing DOTA, so how do these figures apply to Zwift?

Zwift not DOTA

Let’s go back to our sprint finish, where the bunch is riding at 60kph. This equates to 16.7 metres per second, which is just a bit less than one bike length every 100ms. However, your ability to overtake your rival depends on your relative speed, not the absolute figure. Imagine a situation where you make a Herculean effort to increase your speed to 18 metres per second (64.8kph), drawing level with the leader’s rear wheel with 30 metres to go. To win the race, you have to make up a bike length, say 1.8m, travelling at a measly 1.3m/s faster than the leader. Who will cross the line first?

If you have 30m to go and the leader is a bike length ahead, he only has 28.2m left, taking 1.69 seconds. But at your higher speed you will cover 30m in 1.67 seconds, so you win by about half a wheel. However, if your avatar had responded to your acceleration with a 100ms lag, you would certainly have lost the race. If you experience this level of latency, a slower rider could beat you, just because he is located closer to the gaming server. The speed of your avatar really is limited by the speed of light.

However, sometimes it can feel like a zPower rider is overtaking you at an appreciable proportion of the speed of light. If this really were the case and Zwift wanted to represent the avatar correctly, what would it look like?

E. A. Cryer-Jenkins and P. D. Stevenson Gamow’s cyclist: a new look at relativistic measurements for a binocular observer Published:03 June 2020

The physicist George Gamov posed this question back in 1938. He highlighted the effect of relativistic length contraction, predicted by Einstein’s theory of special relativity. In fact, the avatar would change colour, due to the Doppler shift, and light intensity would fluctuate. These effects would be further be complicated by our binocular vision, causing an unnerving blurring effect. This is helpfully explained in detail by physicists in a recent scientific paper. Surprisingly, there are practical applications for this work that may help interpret data gathered by spacecraft passing objects at very high speeds.

Time to be aerodynamic

The Covid-19 epidemic provided a huge boost to the Zwift streaming service. Confined by a global lockdown, cyclists freed themselves from the boredom of pedalling on a static turbo trainer by logging into one of a broadening range of online virtual worlds. Zwift racing has become particularly popular. While it is relatively straightforward to simulate variations in gradient and even the effects of drafting, it is not possible for riders to demonstrate superior bike handling skills. Nor can racers benefit from adopting a superior aerodynamic position on the bike, in fact this may prove to be a disadvantage.

Setting aside e-doping suspicions, such as riders understating their weights, in the artificial world of a Zwift race, the outcome largely comes down the the ability to sustain a high level of power (watts per kilo). The engagingly competitive nature of simulated races encourages everyone to push their limits. However, since Zwift offers no penalty against maintaining a non-aerodynamic body position on your trainer, it is quite possible that regular Zwifters might become habituated to riding in position that is far from optimal for the road.

Fresh aerodynamics

Once out in the fresh air again, many riders may have noticed improvements in the levels of power they are able to sustain, thanks to the high levels of exertion required to compete on Zwift. But in the real world, when it comes to beating other riders in a race or a time trial, the principle force a rider has to overcome is aerodynamic drag, not electromagnetic resistance.

Maximum speed is attained by adopting a riding position that provides the optimal tradeoff between the ability to generate power and a low level of aerodynamic drag. Drag depends on a rider’s CdA, which represents the drag coefficient multiplied by frontal area. Since power rises with the cube of velocity, there comes a point where it is better to compromise on power in order to reduce frontal area. This is the key to time trialing and successful breakaways.

When the race season begins, skilful and more aerodynamic racers will be able to benefit from drafting in the huge wind shadow created by Zwift diesels, while offering back much less assistance when they pull through. So after prolonged training on Zwift, racers and time trialists really need to focus on improving their aerodynamics

There are various ways to reduce drag, starting withs some basics as described in an earlier blog. Post ride analysis can be performed using Golden Cheetah, BestBikeSplit or MyWindSock. There is also a range of devices that claim to offer real time measurement of CdA. These have been primarily targeted at the TT/triathlon market, but there’s no doubt that these could be incredibly useful for both training or even, perhaps, a race breakaway. Cycling Weekly recently reviewed the Notio device, but, while useful, these tools remain expensive and a bit clunky.

Whatever you choose to do, stay safe and stay aero.