Added beta distribution for interpersonal distances. #254
This commit is contained in:
parent
c1589a04fc
commit
ce98ba0026
3 changed files with 23 additions and 6 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
|
||||
from cara.monte_carlo.sampleable import LogNormal,LogCustomKernel,CustomKernel,Uniform, Beta
|
||||
|
||||
|
||||
sqrt2pi = np.sqrt(2.*np.pi)
|
||||
|
|
@ -202,5 +202,5 @@ short_range_expiration_distributions = {
|
|||
}
|
||||
|
||||
|
||||
# Fit from Fig 8 a) "stand-stand" in https://www.mdpi.com/1660-4601/17/4/1445/htm
|
||||
short_range_distances = LogNormal(-0.269359136417347, 0.4728300188814934)
|
||||
# Derived from Fig 8 a) "stand-stand" in https://www.mdpi.com/1660-4601/17/4/1445/htm
|
||||
short_range_distances = Beta(alpha=1.4342766632654418, beta=27.49916410927064)
|
||||
|
|
@ -2,6 +2,7 @@ import typing
|
|||
|
||||
import numpy as np
|
||||
from sklearn.neighbors import KernelDensity # type: ignore
|
||||
from scipy.stats import beta
|
||||
|
||||
import cara.models
|
||||
|
||||
|
|
@ -130,6 +131,22 @@ 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):
|
||||
# these are resp. the alpha and beta of the underlying distribution
|
||||
self.alpha = alpha
|
||||
self.beta = beta
|
||||
|
||||
def generate_samples(self, size: int) -> float_array_size_n:
|
||||
return beta.rvs(a = self.alpha, b = self.beta, loc=0.5, scale=7, 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, 15.24806213],
|
||||
[10.6, 15.24806213],
|
||||
[11.0, 15.24806213],
|
||||
[10.5, 7.491771],
|
||||
[10.6, 7.491771],
|
||||
[11.0, 7.491771],
|
||||
[12.0, 0.],
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue