Compare commits
3 Commits
6dda5f9c00
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7e79e1671
|
||
|
|
2c9b70e075
|
||
|
|
154b193da9
|
29
covidrisk.py
Normal file → Executable file
29
covidrisk.py
Normal file → Executable file
@@ -2,6 +2,11 @@
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def get_data():
|
||||
n_14_day_tests = 7366.1
|
||||
n_14_day_positive_tests = (18.2 + 7.1) / 100 * n_14_day_tests
|
||||
return (n_14_day_tests, n_14_day_positive_tests)
|
||||
|
||||
def p_meet_positive(groupsize:int):
|
||||
'''
|
||||
Naive approach, only works if each individual gets tested.
|
||||
@@ -12,14 +17,14 @@ def p_meet_positive(groupsize:int):
|
||||
|
||||
return (1 - ( 1 - p_positive )**groupsize) * 100
|
||||
|
||||
def p_meet_positive_bayes(groupsize:int):
|
||||
def p_meet_positive_bayes(groupsize:int, n_positive_tests:float, n_tests:float):
|
||||
'''
|
||||
Bayesian approach
|
||||
'''
|
||||
n_positive_tests = 824.11 # number of positive tests in the last 14 days per 100k
|
||||
n_tests = 6514.83 # number of tests in the last 14 days per 100k
|
||||
n_population = 100000 # sample size (per 100k)
|
||||
p_test_positive = 0.5 # probability of a positive person getting tested (0.5 is optimistic...)
|
||||
#n_positive_tests = n_tests_pos # number of positive tests in the last 14 days
|
||||
#n_tests = n_tests_tot # total number of tests in the last 14 days
|
||||
n_population = 100000 # sample size -> per 100k for switzerland
|
||||
p_test_positive = 0.3 # probability of a positive person getting tested (0.5 is optimistic...)
|
||||
|
||||
p_positive_test = n_positive_tests / n_tests
|
||||
p_test = n_tests / n_population
|
||||
@@ -29,15 +34,19 @@ def p_meet_positive_bayes(groupsize:int):
|
||||
|
||||
def plot_data(data):
|
||||
plt.plot(data)
|
||||
plt.title("probability of having a covid positive in groupsize of n")
|
||||
plt.title("likelihood of having a covid positive in groupsize of n")
|
||||
plt.xlabel("group size / n")
|
||||
plt.ylabel("probability / %")
|
||||
plt.grid(visible=True)
|
||||
plt.grid(linestyle='--', linewidth='0.1')
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
tests, pos = get_data()
|
||||
|
||||
data = []
|
||||
for i in range(1, 325):
|
||||
data.append(p_meet_positive_bayes(i))
|
||||
print(f'The chance of meeting a positive in a group of {i} is: {p_meet_positive_bayes(i)}%')
|
||||
for i in range(1, 70):
|
||||
data.append(p_meet_positive_bayes(i, tests, pos))
|
||||
print(f'The chance of meeting a positive in a group of {i} is: {p_meet_positive_bayes(i, tests, pos)}%')
|
||||
|
||||
plot_data(data)
|
||||
|
||||
Reference in New Issue
Block a user