From 8f3e279045e3ee2abb179af7dc0ccbffdaa102a0 Mon Sep 17 00:00:00 2001 From: markus Date: Mon, 25 Jan 2021 14:13:21 +0100 Subject: [PATCH] add lognormal method --- cara/montecarlo.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cara/montecarlo.py b/cara/montecarlo.py index c81cbe89..62229843 100644 --- a/cara/montecarlo.py +++ b/cara/montecarlo.py @@ -32,6 +32,11 @@ log_viral_load_frequencies = ((1.880302953, 2.958422139, 3.308759599, 3.67692158 0.005084746, 0.002966102)) +def lognormal(csi: float, lamb: float, samples: int) -> np.ndarray: + sf_norm = sct.norm.sf(np.random.normal(size=samples)) + return sct.lognorm.isf(sf_norm, csi, loc=0, scale=np.exp(lamb)) + + @dataclass(frozen=True) class MCVirus: #: Biological decay (inactivation of the virus in air)