Compare commits

...

1 Commits

Author SHA1 Message Date
aaron
e7e79e1671 add get data function dummy 2021-11-30 15:12:51 +01:00

25
covidrisk.py Normal file → Executable file
View File

@@ -2,6 +2,11 @@
import matplotlib.pyplot as plt 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): def p_meet_positive(groupsize:int):
''' '''
Naive approach, only works if each individual gets tested. Naive approach, only works if each individual gets tested.
@@ -12,12 +17,12 @@ def p_meet_positive(groupsize:int):
return (1 - ( 1 - p_positive )**groupsize) * 100 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 Bayesian approach
''' '''
n_positive_tests = 1863.6 # number of positive tests in the last 14 days #n_positive_tests = n_tests_pos # number of positive tests in the last 14 days
n_tests = 7366.1 # total number of 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 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_test_positive = 0.3 # probability of a positive person getting tested (0.5 is optimistic...)
@@ -35,9 +40,13 @@ def plot_data(data):
plt.grid(linestyle='--', linewidth='0.1') plt.grid(linestyle='--', linewidth='0.1')
plt.show() plt.show()
data = [] if __name__ == "__main__":
for i in range(1, 70):
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)}%')
plot_data(data) tests, pos = get_data()
data = []
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)