Skip to content

Instantly share code, notes, and snippets.

@scotchi
Last active November 29, 2021 21:33
Show Gist options
  • Save scotchi/3105935d8e2c4233ea46adc4162bd449 to your computer and use it in GitHub Desktop.
Save scotchi/3105935d8e2c4233ea46adc4162bd449 to your computer and use it in GitHub Desktop.
Very simple model to try to calculate how long it'll be before everyone on the planet has had Covid
#!/usr/bin/env ruby
require 'active_support/all'
ACTIVE_CASES = 25000000.to_f
TOTAL_WORLD_CASES = 260000000.to_f
INCUBATION_DAYS = 3
RECOVERY_DAYS = 10
WORLD_POPULATION = 8600000000
R = 1.135
currently_infected = ACTIVE_CASES
incubating = []
recovering = [ ACTIVE_CASES ]
total_infected = TOTAL_WORLD_CASES
day = 0
while total_infected < WORLD_POPULATION
day += 1
recovering.push(incubating.shift) unless incubating.size < INCUBATION_DAYS
recovering.shift if recovering.size > RECOVERY_DAYS
incubating.push(recovering.sum * (R / RECOVERY_DAYS.to_f))
total_infected += incubating.last
printf("Day: %i, New cases: %s, Total infected: %s\n",
day,
incubating.last.to_s(:rounded, precision: 2, separator: '.', delimiter: ','),
total_infected.to_s(:rounded, precision: 2, separator: '.', delimiter: ','))
end
@scotchi
Copy link
Author

scotchi commented Nov 29, 2021

When will everyone on the planet have had Covid by?

Weirdly, this is a statistic that I haven't heard talked much about: when should Covid saturate the human population?

Obviously a real world epidemiological model would be a lot more complicated, but I wanted to start with the basic numbers that we hear all the time:

  • r-value (about 1.135 since the start of the pandemic)
  • Current number of total world cases (around 260 million)
  • Current number of active cases (around 25 million)

I computed the r-value since the beginning of the pandemic. It's around 1.135. Everyone should have had Covid by:

  • With an r-value of 1.135, we'd be looking at June 26, 2022.
  • With an r-value of 1.05, we'd be looking at January 12, 2023.

This model doesn't count for reinfections. It also takes the current counted number of Covid infections, which is almost certainly severely under-reported. It's also extremely simplistic, but makes it possible to play around with the implications of different values.

Day: 1, New cases: 2,837,500.00, Total infected: 262,837,500.00
Day: 2, New cases: 2,837,500.00, Total infected: 265,675,000.00
Day: 3, New cases: 2,837,500.00, Total infected: 268,512,500.00
Day: 4, New cases: 3,159,556.25, Total infected: 271,672,056.25
Day: 5, New cases: 3,481,612.50, Total infected: 275,153,668.75
Day: 6, New cases: 3,803,668.75, Total infected: 278,957,337.50
Day: 7, New cases: 4,162,278.38, Total infected: 283,119,615.88
Day: 8, New cases: 4,557,441.40, Total infected: 287,677,057.29
Day: 9, New cases: 4,989,157.81, Total infected: 292,666,215.09
Day: 10, New cases: 5,461,576.40, Total infected: 298,127,791.50
Day: 11, New cases: 5,978,846.00, Total infected: 304,106,637.50
Day: 12, New cases: 6,545,115.41, Total infected: 310,651,752.91
Day: 13, New cases: 4,327,504.33, Total infected: 314,979,257.25
Day: 14, New cases: 4,684,047.11, Total infected: 319,663,304.35
Day: 15, New cases: 5,104,861.46, Total infected: 324,768,165.81
Day: 16, New cases: 5,273,976.95, Total infected: 330,042,142.76
Day: 17, New cases: 5,447,006.66, Total infected: 335,489,149.42
Day: 18, New cases: 5,631,245.42, Total infected: 341,120,394.83
Day: 19, New cases: 5,798,125.40, Total infected: 346,918,520.23
Day: 20, New cases: 5,943,942.06, Total infected: 352,862,462.28
Day: 21, New cases: 6,065,818.81, Total infected: 358,928,281.10
Day: 22, New cases: 6,157,636.63, Total infected: 365,085,917.73
Day: 23, New cases: 6,212,385.13, Total infected: 371,298,302.86
Day: 24, New cases: 6,222,256.55, Total infected: 377,520,559.41
Day: 25, New cases: 6,178,277.71, Total infected: 383,698,837.12
Day: 26, New cases: 6,392,211.68, Total infected: 390,091,048.79
Day: 27, New cases: 6,566,798.45, Total infected: 396,657,847.24
Day: 28, New cases: 6,688,631.19, Total infected: 403,346,478.44
Day: 29, New cases: 6,815,550.84, Total infected: 410,162,029.27
Day: 30, New cases: 6,942,647.20, Total infected: 417,104,676.48
Day: 31, New cases: 7,062,660.49, Total infected: 424,167,336.97
Day: 32, New cases: 7,178,138.28, Total infected: 431,345,475.24
Day: 33, New cases: 7,291,491.31, Total infected: 438,636,966.55
Day: 34, New cases: 7,404,632.84, Total infected: 446,041,599.39
Day: 35, New cases: 7,520,459.78, Total infected: 453,562,059.17
Day: 36, New cases: 7,642,938.33, Total infected: 461,204,997.50
Day: 37, New cases: 7,777,138.04, Total infected: 468,982,135.54
Day: 38, New cases: 7,929,475.70, Total infected: 476,911,611.24
Day: 39, New cases: 8,071,433.18, Total infected: 484,983,044.42
Day: 40, New cases: 8,208,806.72, Total infected: 493,191,851.14
Day: 41, New cases: 8,349,642.57, Total infected: 501,541,493.71
Day: 42, New cases: 8,492,185.22, Total infected: 510,033,678.93
Day: 43, New cases: 8,635,894.32, Total infected: 518,669,573.26
Day: 44, New cases: 8,781,966.79, Total infected: 527,451,540.05
Day: 45, New cases: 8,931,111.12, Total infected: 536,382,651.17
Day: 46, New cases: 9,083,700.86, Total infected: 545,466,352.03
Day: 47, New cases: 9,240,028.26, Total infected: 554,706,380.29
Day: 48, New cases: 9,400,137.19, Total infected: 564,106,517.49
Day: 49, New cases: 9,563,663.74, Total infected: 573,670,181.23
Day: 50, New cases: 9,729,701.78, Total infected: 583,399,883.00
Day: 51, New cases: 9,896,621.86, Total infected: 593,296,504.86
Day: 52, New cases: 10,065,990.03, Total infected: 603,362,494.89
Day: 53, New cases: 10,238,611.62, Total infected: 613,601,106.51
Day: 54, New cases: 10,414,193.77, Total infected: 624,015,300.27
Day: 55, New cases: 10,592,820.61, Total infected: 634,608,120.88
Day: 56, New cases: 10,774,729.02, Total infected: 645,382,849.91
Day: 57, New cases: 10,959,986.79, Total infected: 656,342,836.69
Day: 58, New cases: 11,148,590.81, Total infected: 667,491,427.51
Day: 59, New cases: 11,340,522.51, Total infected: 678,831,950.01
Day: 60, New cases: 11,535,737.80, Total infected: 690,367,687.82
Day: 61, New cases: 11,734,187.29, Total infected: 702,101,875.10
Day: 62, New cases: 11,935,860.76, Total infected: 714,037,735.86
Day: 63, New cases: 12,140,845.85, Total infected: 726,178,581.71
Day: 64, New cases: 12,349,409.52, Total infected: 738,527,991.23
Day: 65, New cases: 12,561,639.85, Total infected: 751,089,631.08
Day: 66, New cases: 12,777,543.44, Total infected: 763,867,174.51
Day: 67, New cases: 12,997,190.42, Total infected: 776,864,364.94
Day: 68, New cases: 13,220,651.41, Total infected: 790,085,016.34
Day: 69, New cases: 13,447,970.84, Total infected: 803,532,987.19
Day: 70, New cases: 13,679,193.46, Total infected: 817,212,180.64
Day: 71, New cases: 13,914,372.33, Total infected: 831,126,552.98
Day: 72, New cases: 14,153,567.72, Total infected: 845,280,120.70
Day: 73, New cases: 14,396,849.94, Total infected: 859,676,970.63
Day: 74, New cases: 14,644,300.94, Total infected: 874,321,271.57
Day: 75, New cases: 14,896,010.68, Total infected: 889,217,282.25
Day: 76, New cases: 15,152,067.14, Total infected: 904,369,349.39
Day: 77, New cases: 15,412,537.32, Total infected: 919,781,886.71
Day: 78, New cases: 15,677,488.41, Total infected: 935,459,375.12
Day: 79, New cases: 15,946,996.85, Total infected: 951,406,371.97
Day: 80, New cases: 16,221,138.72, Total infected: 967,627,510.69
Day: 81, New cases: 16,499,989.72, Total infected: 984,127,500.41
Day: 82, New cases: 16,783,629.17, Total infected: 1,000,911,129.58
Day: 83, New cases: 17,072,139.96, Total infected: 1,017,983,269.54
Day: 84, New cases: 17,365,607.53, Total infected: 1,035,348,877.08
Day: 85, New cases: 17,664,119.51, Total infected: 1,053,012,996.58
Day: 86, New cases: 17,967,764.93, Total infected: 1,070,980,761.51
Day: 87, New cases: 18,276,633.22, Total infected: 1,089,257,394.74
Day: 88, New cases: 18,590,813.58, Total infected: 1,107,848,208.31
Day: 89, New cases: 18,910,395.28, Total infected: 1,126,758,603.59
Day: 90, New cases: 19,235,470.16, Total infected: 1,145,994,073.75
Day: 91, New cases: 19,566,132.57, Total infected: 1,165,560,206.32
Day: 92, New cases: 19,902,478.29, Total infected: 1,185,462,684.61
Day: 93, New cases: 20,244,604.91, Total infected: 1,205,707,289.51
Day: 94, New cases: 20,592,612.12, Total infected: 1,226,299,901.63
Day: 95, New cases: 20,946,601.50, Total infected: 1,247,246,503.13
Day: 96, New cases: 21,306,676.27, Total infected: 1,268,553,179.40
Day: 97, New cases: 21,672,941.29, Total infected: 1,290,226,120.68
Day: 98, New cases: 22,045,502.99, Total infected: 1,312,271,623.68
Day: 99, New cases: 22,424,469.43, Total infected: 1,334,696,093.10
Day: 100, New cases: 22,809,950.39, Total infected: 1,357,506,043.50
Day: 101, New cases: 23,202,057.64, Total infected: 1,380,708,101.14
Day: 102, New cases: 23,600,905.06, Total infected: 1,404,309,006.20
Day: 103, New cases: 24,006,608.57, Total infected: 1,428,315,614.77
Day: 104, New cases: 24,419,286.06, Total infected: 1,452,734,900.83
Day: 105, New cases: 24,839,057.50, Total infected: 1,477,573,958.33
Day: 106, New cases: 25,266,044.92, Total infected: 1,502,840,003.25
Day: 107, New cases: 25,700,372.41, Total infected: 1,528,540,375.66
Day: 108, New cases: 26,142,166.17, Total infected: 1,554,682,541.83
Day: 109, New cases: 26,591,554.51, Total infected: 1,581,274,096.33
Day: 110, New cases: 27,048,667.94, Total infected: 1,608,322,764.27
Day: 111, New cases: 27,513,639.21, Total infected: 1,635,836,403.48
Day: 112, New cases: 27,986,603.37, Total infected: 1,663,823,006.85
Day: 113, New cases: 28,467,697.81, Total infected: 1,692,290,704.66
Day: 114, New cases: 28,957,062.32, Total infected: 1,721,247,766.97
Day: 115, New cases: 29,454,839.07, Total infected: 1,750,702,606.05
Day: 116, New cases: 29,961,172.70, Total infected: 1,780,663,778.75
Day: 117, New cases: 30,476,210.31, Total infected: 1,811,139,989.06
Day: 118, New cases: 31,000,101.52, Total infected: 1,842,140,090.57
Day: 119, New cases: 31,532,998.52, Total infected: 1,873,673,089.09
Day: 120, New cases: 32,075,056.12, Total infected: 1,905,748,145.21
Day: 121, New cases: 32,626,431.78, Total infected: 1,938,374,577.00
Day: 122, New cases: 33,187,285.68, Total infected: 1,971,561,862.67
Day: 123, New cases: 33,757,780.74, Total infected: 2,005,319,643.41
Day: 124, New cases: 34,338,082.69, Total infected: 2,039,657,726.10
Day: 125, New cases: 34,928,360.14, Total infected: 2,074,586,086.24
Day: 126, New cases: 35,528,784.55, Total infected: 2,110,114,870.79
Day: 127, New cases: 36,139,530.36, Total infected: 2,146,254,401.15
Day: 128, New cases: 36,760,775.00, Total infected: 2,183,015,176.15
Day: 129, New cases: 37,392,698.95, Total infected: 2,220,407,875.10
Day: 130, New cases: 38,035,485.77, Total infected: 2,258,443,360.87
Day: 131, New cases: 38,689,322.21, Total infected: 2,297,132,683.08
Day: 132, New cases: 39,354,398.21, Total infected: 2,336,487,081.29
Day: 133, New cases: 40,030,906.98, Total infected: 2,376,517,988.27
Day: 134, New cases: 40,719,045.04, Total infected: 2,417,237,033.31
Day: 135, New cases: 41,419,012.31, Total infected: 2,458,656,045.62
Day: 136, New cases: 42,131,012.14, Total infected: 2,500,787,057.77
Day: 137, New cases: 42,855,251.37, Total infected: 2,543,642,309.13
Day: 138, New cases: 43,591,940.39, Total infected: 2,587,234,249.52
Day: 139, New cases: 44,341,293.22, Total infected: 2,631,575,542.75
Day: 140, New cases: 45,103,527.56, Total infected: 2,676,679,070.30
Day: 141, New cases: 45,878,864.83, Total infected: 2,722,557,935.13
Day: 142, New cases: 46,667,530.28, Total infected: 2,769,225,465.41
Day: 143, New cases: 47,469,753.02, Total infected: 2,816,695,218.43
Day: 144, New cases: 48,285,766.11, Total infected: 2,864,980,984.54
Day: 145, New cases: 49,115,806.60, Total infected: 2,914,096,791.13
Day: 146, New cases: 49,960,115.62, Total infected: 2,964,056,906.76
Day: 147, New cases: 50,818,938.46, Total infected: 3,014,875,845.22
Day: 148, New cases: 51,692,524.62, Total infected: 3,066,568,369.84
Day: 149, New cases: 52,581,127.86, Total infected: 3,119,149,497.70
Day: 150, New cases: 53,485,006.35, Total infected: 3,172,634,504.04
Day: 151, New cases: 54,404,422.66, Total infected: 3,227,038,926.70
Day: 152, New cases: 55,339,643.89, Total infected: 3,282,378,570.59
Day: 153, New cases: 56,290,941.73, Total infected: 3,338,669,512.31
Day: 154, New cases: 57,258,592.54, Total infected: 3,395,928,104.86
Day: 155, New cases: 58,242,877.44, Total infected: 3,454,170,982.30
Day: 156, New cases: 59,244,082.36, Total infected: 3,513,415,064.65
Day: 157, New cases: 60,262,498.16, Total infected: 3,573,677,562.81
Day: 158, New cases: 61,298,420.70, Total infected: 3,634,975,983.50
Day: 159, New cases: 62,352,150.92, Total infected: 3,697,328,134.43
Day: 160, New cases: 63,423,994.95, Total infected: 3,760,752,129.37
Day: 161, New cases: 64,514,264.15, Total infected: 3,825,266,393.52
Day: 162, New cases: 65,623,275.27, Total infected: 3,890,889,668.79
Day: 163, New cases: 66,751,350.47, Total infected: 3,957,641,019.27
Day: 164, New cases: 67,898,817.48, Total infected: 4,025,539,836.75
Day: 165, New cases: 69,066,009.65, Total infected: 4,094,605,846.40
Day: 166, New cases: 70,253,266.04, Total infected: 4,164,859,112.44
Day: 167, New cases: 71,460,931.57, Total infected: 4,236,320,044.01
Day: 168, New cases: 72,689,357.08, Total infected: 4,309,009,401.08
Day: 169, New cases: 73,938,899.42, Total infected: 4,382,948,300.51
Day: 170, New cases: 75,209,921.62, Total infected: 4,458,158,222.12
Day: 171, New cases: 76,502,792.90, Total infected: 4,534,661,015.02
Day: 172, New cases: 77,817,888.85, Total infected: 4,612,478,903.87
Day: 173, New cases: 79,155,591.53, Total infected: 4,691,634,495.39
Day: 174, New cases: 80,516,289.54, Total infected: 4,772,150,784.93
Day: 175, New cases: 81,900,378.18, Total infected: 4,854,051,163.11
Day: 176, New cases: 83,308,259.54, Total infected: 4,937,359,422.66
Day: 177, New cases: 84,740,342.62, Total infected: 5,022,099,765.27
Day: 178, New cases: 86,197,043.45, Total infected: 5,108,296,808.72
Day: 179, New cases: 87,678,785.21, Total infected: 5,195,975,593.93
Day: 180, New cases: 89,185,998.36, Total infected: 5,285,161,592.30
Day: 181, New cases: 90,719,120.77, Total infected: 5,375,880,713.06
Day: 182, New cases: 92,278,597.80, Total infected: 5,468,159,310.87
Day: 183, New cases: 93,864,882.51, Total infected: 5,562,024,193.38
Day: 184, New cases: 95,478,435.73, Total infected: 5,657,502,629.11
Day: 185, New cases: 97,119,726.19, Total infected: 5,754,622,355.30
Day: 186, New cases: 98,789,230.72, Total infected: 5,853,411,586.02
Day: 187, New cases: 100,487,434.31, Total infected: 5,953,899,020.34
Day: 188, New cases: 102,214,830.31, Total infected: 6,056,113,850.65
Day: 189, New cases: 103,971,920.54, Total infected: 6,160,085,771.19
Day: 190, New cases: 105,759,215.45, Total infected: 6,265,844,986.64
Day: 191, New cases: 107,577,234.26, Total infected: 6,373,422,220.90
Day: 192, New cases: 109,426,505.12, Total infected: 6,482,848,726.02
Day: 193, New cases: 111,307,565.26, Total infected: 6,594,156,291.28
Day: 194, New cases: 113,220,961.14, Total infected: 6,707,377,252.42
Day: 195, New cases: 115,167,248.62, Total infected: 6,822,544,501.04
Day: 196, New cases: 117,146,993.11, Total infected: 6,939,691,494.15
Day: 197, New cases: 119,160,769.75, Total infected: 7,058,852,263.90
Day: 198, New cases: 121,209,163.54, Total infected: 7,180,061,427.44
Day: 199, New cases: 123,292,769.57, Total infected: 7,303,354,197.01
Day: 200, New cases: 125,412,193.14, Total infected: 7,428,766,390.16
Day: 201, New cases: 127,568,049.97, Total infected: 7,556,334,440.12
Day: 202, New cases: 129,760,966.33, Total infected: 7,686,095,406.45
Day: 203, New cases: 131,991,579.30, Total infected: 7,818,086,985.75
Day: 204, New cases: 134,260,536.88, Total infected: 7,952,347,522.63
Day: 205, New cases: 136,568,498.23, Total infected: 8,088,916,020.86
Day: 206, New cases: 138,916,133.82, Total infected: 8,227,832,154.68
Day: 207, New cases: 141,304,125.67, Total infected: 8,369,136,280.35
Day: 208, New cases: 143,733,167.50, Total infected: 8,512,869,447.85
Day: 209, New cases: 146,203,964.97, Total infected: 8,659,073,412.82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment