epistoch.utils package¶
Submodules¶
epistoch.utils.plotting module¶
Created on Tue Apr 21 17:14:05 2020
@author: Germán Riaño
-
epistoch.utils.plotting.
plot_IR
(model, fig=None, linestyle='-', title=None, legend_fmt={'loc': 'best', 'shadow': True}, use_latex=False)[source]¶
epistoch.utils.stats module¶
Created on Wed Apr 15 15:14:55 2020
@author: Germán Riaño
-
class
epistoch.utils.stats.
ConstantDist
(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)[source]¶ Bases:
scipy.stats._distn_infrastructure.rv_continuous
-
epistoch.utils.stats.
get_gamma
(mu, sigma)[source]¶ Builds a gamma distribution from mean and standard deviation for this variable.
Parameters: - mu (double) – The expected value
- sigma (double) – standard deviation
Returns: Return type: A frozen ditribution object
-
epistoch.utils.stats.
get_lognorm
(mu, sigma)[source]¶ Builds a lognormal distribution from mean and standard deviation for this variable. (Not the mean and sd of the corresponding normal)
Parameters: - mu (double) – The expected value
- sigma (double) – standard deviation
Returns: Return type: A frozen ditribution object
-
epistoch.utils.stats.
loss_function
(dist, force=False)[source]¶ Creates a loss function of order 1 for a distribution from scipy
Parameters: - dist (scipy.stats._distn_infrastructure.rv_froze) – a distribution object form scipy.stats
- force (boolean) – whether force an integral computation instead of known formula
Returns: Return type: Callable that represent this loss function
epistoch.utils.utils module¶
-
epistoch.utils.utils.
compute_integral
(n, delta, S, I, times, survival, pdfs, loss1, dist, method='loss')[source]¶ Compute the integral needed for the integro-differential model.
In other words, computes
\[\int_0^t g(t-x) I(x)S(x) dx \quad \text{ for } t = n*\delta\]Parameters: - n (integer) – upper limit for integral.
- delta (float) – interval size
- S (array) – Susceptible
- I (array) – Infected
- times (array) – times at which the arraya are evaluated
- survival (array of float) – array \(G_k \equiv P\{ T > k\delta\}\).
- pdfs (array of float) – array \(g(k\delta)\).
- array float (loss1) – \(L_k\equiv L(k\delta)\)
- dist (rv_continuous) – Object that represents the distribution
- method (string) – One from “loss”, “simpson” or “interpolate”
Returns: Return type: Value of the integral
-
epistoch.utils.utils.
get_total_infected
(reproductive_factor, normalized_s0=1)[source]¶ Estimate the total number of infected for a given reproductive factor.
Find the value z that solves
\[1-z = S_0 * e^{{\mathcal R_0} z},\]where \(\mathcal R_0\) is the
reproductive_factor
, and \(S_0\) is the (normalized) initial populationnormalized_s0
.Parameters: - reproductive_factor (float) – Basic reproductive factor.
- normalized_s0 (float, optional) – Initial fraction of population that is infected. The default is 1.
Returns: The stimated fraction of total infected.
Return type: float