Removed beta distribution and added custom distribution for the interpersonal distances distribution
This commit is contained in:
parent
de5552c236
commit
a7bcc3ec2c
3 changed files with 9 additions and 24 deletions
|
|
@ -5,7 +5,7 @@ import numpy as np
|
|||
from scipy import special as sp
|
||||
|
||||
import cara.monte_carlo as mc
|
||||
from cara.monte_carlo.sampleable import LogNormal,LogCustomKernel,CustomKernel,Uniform, Beta
|
||||
from cara.monte_carlo.sampleable import LogNormal,LogCustomKernel,CustomKernel,Uniform, Custom
|
||||
|
||||
|
||||
sqrt2pi = np.sqrt(2.*np.pi)
|
||||
|
|
@ -203,4 +203,8 @@ short_range_expiration_distributions = {
|
|||
|
||||
|
||||
# Derived from Fig 8 a) "stand-stand" in https://www.mdpi.com/1660-4601/17/4/1445/htm
|
||||
short_range_distances = Beta(alpha=0.588715, beta=1.50214, loc=0.5, scale=1.5)
|
||||
distances = np.array((0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2))
|
||||
frequencies = np.array((0.0598036,0.0946154,0.1299152,0.1064905,0.1099066,0.0998209, 0.0845298,0.0479286,0.0406084,0.039795,0.0205997,0.0152316,0.0118155,0.0118155,0.018485,0.0205997))
|
||||
short_range_distances = Custom(bounds=(0.5,2.),
|
||||
function=lambda x: np.interp(x,distances,frequencies,left=0.,right=0.),
|
||||
max_function=0.13)
|
||||
|
|
@ -2,7 +2,6 @@ import typing
|
|||
|
||||
import numpy as np
|
||||
from sklearn.neighbors import KernelDensity # type: ignore
|
||||
from scipy.stats import beta
|
||||
|
||||
import cara.models
|
||||
|
||||
|
|
@ -131,24 +130,6 @@ class LogCustomKernel(SampleableDistribution):
|
|||
return 10 ** kde_model.sample(n_samples=size)[:, 0]
|
||||
|
||||
|
||||
class Beta(SampleableDistribution):
|
||||
"""
|
||||
Defines a Beta distribution parameterized by two positive shape parameters,
|
||||
denoted by alpha (α) and beta (β), that appear as exponents of the random
|
||||
variable and control the shape of the distribution.
|
||||
"""
|
||||
|
||||
def __init__(self, alpha: float, beta: float, loc: float, scale: float):
|
||||
# these are resp. the alpha and beta of the underlying distribution
|
||||
self.alpha = alpha
|
||||
self.beta = beta
|
||||
self.loc = loc
|
||||
self.scale = scale
|
||||
|
||||
def generate_samples(self, size: int) -> float_array_size_n:
|
||||
return beta.rvs(a = self.alpha, b = self.beta, loc=self.loc, scale=self.scale, size=size)
|
||||
|
||||
|
||||
_VectorisedFloatOrSampleable = typing.Union[
|
||||
SampleableDistribution, cara.models._VectorisedFloat,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ def test_dilution_factor(activity, expected_dilution):
|
|||
@pytest.mark.parametrize(
|
||||
"time, expected_short_range_concentration", [
|
||||
[8.5, 0.],
|
||||
[10.5, 8.037883241318065],
|
||||
[10.6, 8.037883241318065],
|
||||
[11.0, 8.037883241318065],
|
||||
[10.5, 5.401601371244907],
|
||||
[10.6, 5.401601371244907],
|
||||
[11.0, 5.401601371244907],
|
||||
[12.0, 0.],
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue