Skip to content

Instantly share code, notes, and snippets.

@kennyyu
Created February 13, 2020 06:17
Show Gist options
  • Save kennyyu/a68b647068551b14e2463d44ec53a99e to your computer and use it in GitHub Desktop.
Save kennyyu/a68b647068551b14e2463d44ec53a99e to your computer and use it in GitHub Desktop.
import math
num_cases_per_day = [
844,
1312,
2015,
2801,
4579,
6061,
7816,
9821,
11948,
14551,
17387,
20626,
24553,
28276,
31439,
34876,
37552,
40553,
]
r = 0.2770347369
K = 51109.43758
errors = []
P0_start = 1312
P0_end = 2015
for P0 in range(P0_start, P0_end):
total_error = sum(
(K / (1 + ((K - P0) / P0) * math.exp(- r * t)) - cases) ** 2
for (t, cases) in enumerate(num_cases_per_day)
)
errors.append((P0, total_error))
for (P0, total_error) in errors:
print("{},{}".format(P0, total_error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment