-
Notifications
You must be signed in to change notification settings - Fork 0
/
R0.py
executable file
·33 lines (26 loc) · 1.03 KB
/
R0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
'''Compute the basic reproduction number, R_0, for each of the acute
and chronic models and each of the 3 SATs.
Assumptions:
* Constant population size, particularly no seasonal births.
* All susceptible, so drop M.
* Mortality is negligible, so S->E->I is equivalent to S->I,
among other simplifications.
* Transmission rate for both acute and chronic scales so that R_0 is
independent of population size.'''
import herd.samples
def calculate(model, SAT, alpha=0.05):
s = herd.samples.load(model=model, SAT=SAT)
R0 = s.recovery_mean * s.transmission_rate
if model == 'chronic':
R0 += (s.probability_chronic
* s.chronic_recovery_mean
* s.chronic_transmission_rate)
R0 = R0.quantile([0.5, alpha / 2, 1 - alpha / 2])
return R0
if __name__ == '__main__':
print('model\tSAT\tR_0')
for model in ('acute', 'chronic'):
for SAT in (1, 2, 3):
print('{}\t{}\t{:.1f}\t({:.1f}, {:.1f})'.format(
model, SAT, *calculate(model, SAT)))