API reference
ChainBinomial
Bases: ABC
General chain binomial model
Source code in src/reedfrost/__init__.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
_pi(i)
abstractmethod
_pmf_binom(k, n, p)
staticmethod
Binomial distribution pmf
This implementation is substantially faster than scipy.stats.binom.pmf
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k
|
int
|
number of successes |
required |
n
|
int
|
number of trials |
required |
p
|
float
|
success probability |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
probability mass |
Source code in src/reedfrost/__init__.py
_tp(i, si, ip)
cached
_validate_params(params)
abstractmethod
prob_final_i_cum(i_cum)
Probability of a certain number of total infections, including the initial infection(s)
Source code in src/reedfrost/__init__.py
prob_final_i_cum_extra(k)
Probability of a certain number of infection beyond the initial infection(s)
prob_final_s(s_inf)
prob_state(s, i, t)
cached
Probability of being in state (s, i) at time t
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
int
|
number of susceptibles |
required |
i
|
int
|
number of infected |
required |
t
|
int
|
generation |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
probability mass |
Source code in src/reedfrost/__init__.py
simulate(rng=np.random.default_rng())
Simulate a Reed-Frost outbreak
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rng
|
Generator
|
random number generator |
default_rng()
|
Returns:
Type | Description |
---|---|
NDArray[integer]
|
NDArray[np.integer]: number of infected in each generation |
Source code in src/reedfrost/__init__.py
Enko
Bases: ChainBinomial
Enko model
Source code in src/reedfrost/__init__.py
_validate_params(params)
staticmethod
Validate parameters for the Enko model
Greenwood
Bases: ChainBinomial
Greenwood model
Source code in src/reedfrost/__init__.py
_validate_params(params)
staticmethod
ReedFrost
Bases: ChainBinomial
Reed-Frost model