Skip to content

Instantly share code, notes, and snippets.

@kennyyu

kennyyu/total_error.py Secret

Created Feb 13, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.