Blog

Meanwhile in a country that takes COVID-19 seriously…

This was the scene on Australian TV at around 7 AM U.S. Eastern Time this morning:

Look at the size of that crowd – 49,000 people together at the Melbourne Cricket Ground, hardly even needing to keep their distance from one another. Hear the joy of Richmond Tigers fans as they sing their team’s fight song after winning the opening game of the Australian Football League season. Watch players from the Tigers and even the losing Carlton Blues shaking hands and giving out hugs and high-fives after 80 minutes of running the equivalent of the 40-yard dash one hundred and six times.

This could be us, America.

What has the state of the pandemic been like in Australia and in the United States? As always, a graph is worth a million words:

Cases in the U.S. go up to 900 per million people per day, while cases in Australia go up to 20 per million people per day
Newly-diagnosed cases per million people per day in the USA (blue line) and Australia (orange line)

The graph shows why Australians are beginning to get back to their normal lives, even though the vaccination rate in Australia is still lower than the vaccination rate in the U.S.

It’s striking to watch normal life happen, right now, from a country where 1,000 people are still dying of COVID-19 every single day. How did Australia do it?

The short answer is that nearly everyone had the common sense, personal responsibility, and basic human decency to follow public health guidelines: stay home whenever possible, and when that is not possible, keep a 6-foot or 2-metre distance from others and wear a cloth mask over both your nose and mouth.

Of course, the vast majority of Americans have the common sense, personal responsibility, and basic human decency to follow the same public health guidelines – but one major lesson we have learned from this pandemic is that even “the vast majority” is not enough. It takes nearly everyone, no exceptions. (I’d love to be able to say something more quantifiable here, and I’m doing some research. As I learn more, I’ll add it here.)

But you might say, what about TEH ECONOMY (TM)? Has Australia sacrificed economic growth, and therefore livelihoods, by adhering too strictly to public health guidelines? Maybe yes, maybe no.

The graph below shows the quarterly per capita gross domestic product (GDP) in the U.S. and Australia, relative to the fourth quarter of 2019 before the pandemic reached either country.

Gross Domestic Product in US Dollars for the US and Australia, relative to Q4-2019 values

All the social distancing did indeed cost the Australian economy – the economy contracted more than the US economy did in quarter 2 of 2020, at the height of the pandemic.

But here’s the thing: the pain was temporary. By the third quarter of 2020, Australia was already outperforming the US, and now the Australian economy is stronger than it was before the pandemic began.

Adding up all quarters, it’s not entirely clear whose economy has been healthier overall. But the more football tickets Australians buy and Americans don’t, the more clear it would become that Australia would come out on top.

And – let’s not focus on the economy so obsessively that we lose sight of actual human lives – it’s absolutely clear and obvious that in terms of lives lost to the pandemic, Australia is the clear and obvious winner.

If you’re going to say that the U.S. can’t learn from Australia, or you that can’t compare two different countries, I’m going to say: well, why?

Why is a constitutional federal republic of states with a bicameral legislature and a fiercely independent frontier spirit where the most popular sport is football so massively different from a constitutional federal republic of states with a bicameral legislature and a fiercely independent frontier spirit where the most popular sport is football?

America, this could be us.

Stop making excuses and #MaskUp.

Large Numbers Madness

For sports fans, it’s the most wonderful time of the year: the first week of the NCAA men’s basketball tournament!

The bracket for the 2021 NCAA men's basketball tournament
This year’s NCAA men’s basketball tournament bracket – click for a larger version

Last night, the qualifying teams were announced, along with their matchups in the first round. And here it is – click for a larger version that you can read.

That means that today, millions of people in the U.S. and around the world are carefully studying this bracket, trying to pick the winners of each game in each round, for fun and profit. And so a question that often comes up this time of year is this:

What are the chances of picking a perfect NCAA bracket?

That is, what is the probability of correctly predicting the winner of every single game, from the first first-round game through to the championship?

Seemingly simple games can produce absurdly large numbers quickly, as we saw earlier with a simple deck of cards. March Madness doesn’t produce numbers quite that absurd as the cards did, but still so absurd that it’s hard to wrap your mind around just how large the number is.

The UMBC Retrievers celebrate after winning the first 16-vs-1 matchup in NCAA men's basketball tournament history
Miracles do happen: (16) UMBC 74 (1) Virginia 54 in 2019

Let’s ignore the play-in games on Wednesday night, since those exist only to confuse and annoy. That leaves 64 teams, which means that to crown a champion it will take 63 games. Assume that in each game, each team has a 50-50 chance of winning, meaning you can flip a coin to predict the winner. (This is not a realistic assumption, since for example, the 1-seed has won 139 out of 140 games – but since miracles can happen, let’s go for it.)

That means that the probability of getting every game right is 1 in 263, which is

1 in 9,223,372,036,854,775,808

That’s one correct choice out of 9 quintillion 223 quadrillion 372 trillion 36 billion 854 million 775 thousand 808 possible combinations.

Loki from the Avengers movie series
What kind of divine being would be annoying enough… oh, right. Never mind.

How absurdly huge is this? See below for the calculations, but in short, let me put it this way.

Let’s say that some really annoying divine being decided they wanted to cheat by getting humans to pick every possible bracket. They would have to kidnap every human on Earth – all eight billion of us – and endow us all with eternal life and super-speed to pick brackets.

Then they would magically transport us back to the year 1983, just in time to watch one of the most famous moments in college basketball history:

Then we would get to work – all eight billion of us – picking one possible NCAA bracket per second. No stopping to eat or sleep, just filling out March Madness brackets once per second, all day all night all year. It could have happened earlier, but in the worst case it would be just about now – after about 38 years of work – that someone, somewhere would get a perfect bracket. And that’s just for this year; picking next year’s bracket could keep us busy until the year 2060.

But take heart – you don’t have to get them all right to win your office pool. As they say, you and your friend are being chased by a bear, you don’t have to outrun the bear. You just have to outrun your friend.

Replace the bear in that analogy with the laws of probability, and good luck with your picks this year!

The (highly approximate) calculations

  • There are 263 possible combinations, which is about 9 x 1018
  • There are 8 billion people on Earth (8 x 109)
  • So everyone picking one bracket per second is 8 x 109 brackets per second
  • There are about 30 million seconds in a year (3 x 107)
  • So every human picking one bracket per second for a year multiplies to about 2.4 x 1017 brackets
  • 9 x 1018 brackets divided by 2.4 x 1017 brackets per year is about 38 years

Dealing with large numbers

Take a deck of cards. Give it a good shuffle, and then lay the cards out one by one, like the picture below. Here’s the question:

How many possibilities are there for which cards will go where? And how many times will you likely have to deal to get the same arrangement of cards again?

Fortunately my spouse is a huge nerd and has Lord of the Rings playing cards

To deal a pack of cards, start with the first card. There are 52 possibilities; I got the 7 of spades. Once the first card is dealt, you have 51 cards left, so there are 51 possibilities for what the next card will be. The next card could be one of 50 possibilities, the one after that could be one of 49, and so on – until the last card, which can only have one possibility. To find the total number of possible orderings, multiply out all the possibilities to get:

52 x 51 x 50 x 49 x ………… x 3 x 2 x 1

Math has a special name for this operation: factorial, symbolized with an exclamation point (!). The factorial of a number is equal to that number times the previous number, times the number before that, and so on all the way down to 1. The exclamation mark is an appropriate symbol, because the factorial can get shockingly big shockingly quickly.

The first few:

1! = 1
2! = 2 x 1 = 2
3! = 3 x 2 x 1 = 6
4! = 4 x 3 x 2 x 1 = 24
5! = 5 x 4 x 3 x 2 x 1 = 120
6! = 6 x 5 x 4 x 3 x 2 x 1 = 720
7! = 7 x 6 x 5 x 4 x 3 x 2 x 1 = 5,040
8! = 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 40,320

That means that if you deal seven cards, you have 5,040 possibilities for their order. If you deal eight cards, you have 40,320 possibilities for their order.

What about for the full 52 cards – what does 52! equal?

52! = 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000

That means that when you shuffle and deal a deck of cards, there are 80 unvigintillion 658 vigintillion 175 novemdecillion 170 octodecillion 943 septendecillion 878 sexdecillion 571 quindecillion 660 quattuordecillion 636 tredecillion 856 duodecillion 403 undecillion 766 decillion 975 nonillion 289 octillion 505 septillion 440 sextillion 883 quintillion 277 quadrillion 824 trillion different possibilities for how the cards could fall.

How big a number is that? It is unimaginably, unfathomably, amazingly huge. To call this number “astronomical” would be an insult to astronomy.

To get a sense for exactly how huge this number is, let’s consider the second half of the question I asked above: how many times would you have to deal before you could expect to see the same arrangement of cards again?

Because the cards are shuffled anew each time, every deal is independent of those that came before and after, and thus there is no definitive way or predicting the answer. It could happen again pretty soon, or it could never happen again for the rest of the history of the Universe.

But we can get some insight into the question by considering another random chance event that is much, much more likely: rolling a die. On average, how many times do you have to roll a six-sided die before you might expect to roll a 6?

A table of numbers showing the number of times I had to roll a 6-sided die to get a 6
How many times did I need roll a 6-sided die to get a 6?
Yes, I really did roll a die this many times. I am committed to my art.

If you know enough statistics to know that recurrences occur in a geometric distribution (and if you know why it depends somewhat on what you mean by “you might expect,” you can skip to the answer – but it’s always more fun to figure it out. So I did an experiment. I rolled a die, and kept rolling until I got a 6. I wrote down the number of rolls that it took. And then did it again, and again, a total of 200 times.

Over those 200 trials, the average (mean) number of rolls required to get a six was 6 rolls. I tried again with rolling an 8-sided die, and over 50 trials it took on average 8 rolls to get an 8. And it sort of makes sense that the number of trials you need to get a specific outcome should be roughly equal to the number of possible outcomes.

Which means that for dealing cards, where there are 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 possible outcomes, you should expect to have to deal out the deck 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 times before getting the cars in the same order again.

How many times is that? Here’s a way of thinking about how big that number is, adapted from an essay by fellow data scientist Scott Czep.

Stand in the middle of Times Square in New York City. Deal out deck of cards and note the arrangement. Put the deck back together, shuffle, and take a step. Repeat: deal, shuffle, step. Deal, shuffle, step. Continue until you are standing on the beach in Los Angeles, California. But you’re not done yet. Far from it. Turn around and deal, shuffle, step, all the way back to New York. Then turn around and do the same thing: deal, shuffle step back to LA.

Now take an eyedropper and remove one drop of water from the Pacific Ocean. You’re there anyway. Turn around and deal, shuffle step back to New York, then back to LA. Then remove another drop from the Pacific Ocean.

Continue doing this until the Pacific Ocean is empty.

You’re still not done, though. Magically refill the entire Pacific Ocean, and then remove a pebble from the top of Mount Everest. Turn around and deal, shuffle, step back to New York. Deal, shuffle, step, New York, deal, shuffle, step, LA, drop, New York, LA, drop, New York, LA, drop, ocean empty, pebble off Mount Everest.

Continue until you have removed all of Mount Everest.

Congratulations! You have removed Mount Everest once, after having emptied the Pacific one drop at a time one billion billion times, while walking back and forth between New York and LA between drops, dealing and shuffling cards each time. To celebrate your accomplishment, lay a piece of paper on the ground. Magically refill the Pacific, magically rebuild Mount Everest all the way to the top, and repeat.

Deal, shuffle, step, New York, LA, drop, deal, shuffle, step, New York, LA, drop, ocean empty, pebble, deal, shuffle, step, New York LA, drop, ocean empty, Mount Everest gone, add a sheet of paper to the stack, repeat, keep stacking.

Continue until the stack of papers reaches the Sun.

After all this – countless pieces of paper on the stack, countless countless removals of Everest, countless countless countless emptyings of the Pacific, and countless countless countless countless hands of cards, are you done? No.

Repeat this entire process 66 more times. Sometime during your 67th trip, you reach the number of deals at which you might expect to see the same layout you saw on your first deal, back in New York so long ago.

Think about this next time you see a pack of cards: enormous complexity can hide in the simplest things.

Postscript: The Numbers

Doing these calculations was way easier because Scott Czep did most of the work in his essay about 52 factorial, I just changed a few things. If you see any errors, they are mine rather than his, and please let me know in the comments! And definitely check out Scott’s essay and the rest of his blog.

  • 52! in scientific notation is about 8 x 1067, so that is the number we are aiming for.
  • An average person has a stride length of a bit less than one meter, but let’s round up to 1 meter to make the calculations easier. It’s one hand of cards per step.
  • The distance from New York to Los Angeles is 4500 km, so back and forth is 9000 km = 9 x 107 meters. At one step per meter and one hand of cards per step, that’s 9 x 106 hands. (Note: we’ll ignore the initial New York to LA walk since it will make so little difference with the number of times we’ll have to do the round trip.)
    • Current total: 9 x 107 hands dealt
  • There are about 20 drops of water per cubic millimeter
  • The Pacific Ocean contains 700 million cubic kilometers of water (7 x 108 km3 = 7 x 1023 mL = 1.4 x 1025 drops
    • Current total: 1.2 x 1033 hands dealt
  • Assume a pebble weighs about 1 ounce.
  • Mount Everest weighs 357 trillion pounds = 5.7 x 1015 ounces = 5.7 x 1015 pebbles.
    • Current total: 6.8 x 1048 hands dealt
  • A sheet of paper is about 0.1 mm thick
  • The distance from the Earth to the Sun is 150 billion km = 1.5 x 1017 mm = 1.5 x 1018 sheets of paper
    • Current total: 1.2 x 1066 hands dealt
  • Repeat the entire cycle 66.7 times to get to the target of 8 x 1067 hands

Still Going (Daily COVID-19 data update CCCXXIII)

Graphs day 323, pandemic day 330, day 401 since the first cases were diagnosed.

Total cases of COVID-19 diagnosed worldwide: 103,412,282

Total deaths: 2,232,405

Just a very quick update today while I look into some other trends in more detail. Usual graph formats, click for a larger version of each.

Countries that have consistently gotten it right

Countries where COVID-19 was stayed mostly contained throughout the pandemic

Countries where COVID-19 is currently under control(-ish)

Countries where COVID-19 was bad but are now sort of under-control-ish

Countries moving in the right direction(-ish)

Regions where cases are still high but are currently stable

Countries where the pandemic is still awful

Regions where the epidemic is still raging

Fortunately, even in these countries, cases are beginning to decrease; although in the meantime, Spain has moved ahead of the U.S. into first place on this graph in terms of cases per day.

Methods

Sadly, Corona Data Scraper has stopped reporting data in the way I was using it, so I have gone back to using the data from the JHU Coronavirus Resource Center. You can download the data from their GitHub repository. You are welcome to use my Excel spreadsheet (version 9.2).

Bug Parade: When Gandhis Attack

Sometimes we can learn a great deal about how to do things right from the times when things went wrong. Welcome to a new occasional series: The Bug Parade!

Screenshot from Civilizaiton 1: Mahatma Gandhi, leader of the Indians, says "Very well, we will mobilize our armies for WAR! You will pay for your foolish pride!"
Gandhi attacks

The Civilization series is one of the most enduringly successful computer strategy games of all time. The games let you control a human civilization, starting in 4000 B.C. and guiding them into the 21st century. You control all aspects of your civilization, from military expansion to scientific advancement to keeping your citizens happy. Along the way, you encounter other civilizations and their leaders. You can go to war with these civilizations, make peace, manage alliances, and negotiate with their leaders. The series is one of the most incredibly addictive, just-one-more-turn strategy games ever created.

It all started in 1991 with the original game of that name, now informally known as Civ 1, created by legendary game designer Sid Meier. Nearly 30 years later, the original game still has a devoted fanbase, who not only still play the game but also dig deep into the game’s code to create fan mods to play and share.

Creating a game that people still enjoy after 30 years is an amazing achievement on its own, but it becomes absolutely mind-blowing when you realize that the entire game takes up just 2.6 megabytes of space, less than a single song stored in MP3 format.

Size comparison: the entire game (2.4 Megabytes) against a single MP3 (3.4 Megabytes)

Creating such a complex game in such a tiny amount of storage space necessarily meant that many compromises had to be made – and from one of these compromises came one of the most famous software bugs in history.

In 1991, the Internet had yet to penetrate into public consciousness, and so the idea of playing a game online was still new. Meier knew this, and knew that Civilization presented enough of a design and programming challenge already, so he decided to keep it firmly a one-player strategy game. And that meant that the quality of the game would depend on the quality of the player’s computer-controlled artificial intelligence (AI) opponents. If the AI opponents made good decisions, the single human player could respond to the challenges presented with decisions of their own.

But that was the challenge – how could the game developers make convincing AI for opposing world leaders while making the entire game fit into an absurdly low 2.6 megabytes? All opposing leader decisions where based on a set of simple formulas. Will Hammurabi offer a peace treaty? Check the formula. Will Mao Tse Tung launch a nuclear weapon? Check the formula. And to account for differences between leaders, the input to the formula was a simple scale from 1 to 5, ranging from most peaceful to most warlike: Mahatma Gandhi scored 1, Genghis Khan scored 5.

But there was another game design point to consider. One of the things that made Civilization so groundbreaking was that it had multiple ways to win. You can win by conquering the entire world, by winning the space race, or by having the highest score when the game ends in 2100 AD. To reward the player for sticking around for the modern era, – as well as to reflect historical experience – opponents become less aggressive. Specifically, each leader’s aggression rating drops by two.

But if aggression drops by two, what happens to Gandhi, who already had an aggression rating of one? Logically, his aggression rating should drop to -1, making him even more peaceful than he was already. But if logic prevailed, we wouldn’t be talking about this in a recurring series called The Bug Parade.

Remember that with only 2.6 megabytes to work with, programmers were desperate to save space, so they used every strategy they could think of to make their code use memory efficiently. Since they knew the aggression rating went from 1 to 5, they used only one byte of memory to store the value. One byte of memory can store values from 0 (in binary, 00000000) to 255 (in binary, 11111111). You can probably already see the problem with this.

If the program could only store values from zero to 255, and it had to calculate 2-1, what was it supposed to do? The only thing that made any sense at all was for the odometer to turn over, for the calculation to wrap around, and to return the result 255.

Subtracting 1 from 00000000 (equal to zero) gives 11111111 (equal to 255)
Illustration of an integer underflow error

Thus, as soon as the player discovers Democracy, Gandhi’s aggression jumps to 255.

Out of five.

And so as soon as Gandhi gains the ability to launch nuclear missiles, he immediately launches them at everyone on the next turn, and on every turn after that until he is dead or everyone else is dead.

The bug was never caught in testing, but of course as soon as the game shipped, millions of players discovered it, and it became legend. The bug was quickly fixed in the sequel, but by that point “Nuclear Gandhi” had become enshrined in popular culture.

Memes weren’t really a thing in 1991, but “Nuclear Gandhi” was an inside joke among computer gaming fans for literally decades. And as soon as memes became a thing, Nuclear Gandhi memes became a thing too. Here’s a mashup of Nuclear Gandhi with another famous meme, Der Untergang subtitles:

Coding the game in such a way as to allow a variable underflow error wasn’t even really a mistake, just a design decision that had consequences that were unexpected – and hilarious.

But that’s the nature of the parade – the bugs show up when you least expect them.

I hope you enjoyed this light-hearted introduction to where software bugs come from and what they can do – because when the Bug Parade returns, the next one will be pure nightmare fuel.

400 Days Later (Daily COVID-19 data update CCCXXI)

Graphs day 321, pandemic day 328, day 400 since the first cases were diagnosed. That’s right, it has now been 400 days since Dr. Li Wenliang officially diagnosed the first few cases of the new disease now called Coronavirus Disease 2019 (COVID-19). Just over a month later, Dr. Li had died of the disease.

Today’s sad totals:

Total cases of COVID-19 diagnosed worldwide: 102,579,774

Total deaths: 2,206,445

Remember how we said a few months ago that as we get better at diagnosing less severe cases, the case fatality rate (CFR) would get closer to the biological value, which was likely around 2 percent? The case fatality rate is currently 2.2 percent.

Here are the usual graphs, with countries divided into the same categories as on Tuesday. Countries are color-coded and labeled by name. The thickness of the lines and the sizes of the labels correspond to the case fatality rate in the country – thicker lines and larger labels indicate countries where a larger percentage of COVID-19 cases have led to death. Click on any of the images for a larger version.

Countries that have consistently gotten it right

These countries have consistently kept their per-capita cases of COVID-19 at very low levels.

Countries where COVID-19 was stayed mostly contained throughout the pandemic

When we last checked in last Tuesday, Japan seemed to be in a phase of an increased number of cases. Today, it is much clearer that cases are once again declining in Japan, after having peaked at 40 new cases per million people per day about two weeks ago.

Plenty of people have told me they do not believe the case and death numbers coming out of China. That’s fair enough; there are lots of reasons to not believe China.

But do you believe the case and death numbers coming out of New Zealand, Australia, India, and Japan?

Countries where COVID-19 is currently under control(-ish)

Countries where COVID-19 was bad but are now sort of under-control-ish

When we looked on Tuesday, there seemed to be a slight increase in Chile, Peru, and Canada. The daily case load definitely seems to have decreased in Canada, and seems to be leveling off in Chile and Peru.

Countries moving in the right direction(-ish)

These countries, all in Europe, experienced nightmarish COVID-19 disease waves in the fall – some of the worst in the world – bur fortunately for now have seen cases stabilize at a lower level.

Regions where cases are still high but

The good news is that these three European countries seem to be doing well. Cases continue to decrease in Belgium, Switzerland, and Italy.

The bad news is that Italy is experiencing a wave of sometimes-violent protests against the necessary restaurant closings. If the current protests lead to an increase in COVID-19 cases and deaths in Italy over the next two to four weeks. Obviously I hope they will not, but nature cares not for our hopes. I’ll let you know how it goes either way.

Countries where the pandemic is still awful

Lastly, the countries where the pandemic is still infecting and killing lots and lots of people: Spain, the United States, the United Kingdom, France, Sweden, and Brazil.

Regions experiencing a second wave of cases

Fortunately, even in these countries, cases are beginning to decrease; although in the meantime, Spain has moved ahead of the U.S. into first place on this graph in terms of cases per day.

Methods

Sadly, Corona Data Scraper has stopped reporting data in the way I was using it, so I have gone back to using the data from the JHU Coronavirus Resource Center. You can download the data from their GitHub repository. You are welcome to use my Excel spreadsheet (version 9.2).