Changed short range distance distribution to lognormal
This commit is contained in:
parent
75a7b75496
commit
2165c71bf5
3 changed files with 15 additions and 14 deletions
|
|
@ -250,7 +250,7 @@ class FormData:
|
|||
sr_presence=self.short_range_intervals()
|
||||
sr_activities=self.short_range_activities()
|
||||
short_range_expirations = tuple(short_range_expiration_distributions[activity] for activity in sr_activities)
|
||||
dilutions=dilution_factor(activities=sr_activities, distance=np.random.uniform(0.5, 1.5, 250000))
|
||||
dilutions=dilution_factor(activities=sr_activities)
|
||||
else:
|
||||
sr_presence=()
|
||||
short_range_expirations=()
|
||||
|
|
|
|||
|
|
@ -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 Normal,LogNormal,LogCustomKernel,CustomKernel,Uniform
|
||||
from cara.monte_carlo.sampleable import LogNormal,LogCustomKernel,CustomKernel,Uniform
|
||||
|
||||
|
||||
sqrt2pi = np.sqrt(2.*np.pi)
|
||||
|
|
@ -182,7 +182,11 @@ def expiration_distribution(
|
|||
)
|
||||
|
||||
|
||||
def dilution_factor(activities, distance, D=0.02):
|
||||
def dilution_factor(activities):
|
||||
D = 0.02
|
||||
# From https://www.mdpi.com/1660-4601/17/4/1445/htm
|
||||
distance = LogNormal(0.8542127255693238, 0.42755967248106513).generate_samples(250_000)
|
||||
|
||||
factors = []
|
||||
for activity in activities:
|
||||
u0 = 0.98 if activity == "Breathing" else 3.9
|
||||
|
|
|
|||
|
|
@ -47,10 +47,7 @@ def expirations(presences) -> typing.Tuple[mc_models.Expiration, ...]:
|
|||
|
||||
@pytest.fixture
|
||||
def dilutions(presences):
|
||||
return dilution_factor(
|
||||
activities=[activity for (activity, presence) in presences],
|
||||
distance=np.random.uniform(0.5, 1.5, 250_000),
|
||||
)
|
||||
return dilution_factor(activities=[activity for (activity, presence) in presences])
|
||||
|
||||
|
||||
def test_short_range_model_ndarray(concentration_model, presences, expirations, dilutions):
|
||||
|
|
@ -64,9 +61,9 @@ def test_short_range_model_ndarray(concentration_model, presences, expirations,
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
"start, stop, expected_exposure", [
|
||||
[8.5, 12.5, 5.844666077067048e-09],
|
||||
[10.5, 11.0, 5.830120846251791e-09],
|
||||
[10.6, 11.9, 4.6397748633454945e-09],
|
||||
[8.5, 12.5, 5.963061627547172e-10],
|
||||
[10.5, 11.0, 5.934552264225482e-10],
|
||||
[10.6, 11.9, 4.709684623109963e-10],
|
||||
]
|
||||
)
|
||||
def test_normed_exposure_between_bounds(
|
||||
|
|
@ -76,15 +73,15 @@ def test_normed_exposure_between_bounds(
|
|||
model = mc_models.ShortRangeModel(presences, expirations, dilutions)
|
||||
model = model.build_model(250_000)
|
||||
np.testing.assert_almost_equal(
|
||||
model.normed_exposure_between_bounds(concentration_model, start, stop).mean(), expected_exposure
|
||||
model.normed_exposure_between_bounds(concentration_model, start, stop).mean(), expected_exposure, decimal=10
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"time, expected_sr_normed_concentration, expected_concentration", [
|
||||
[10.75, 1.1670056689678455e-08, 11.67005668967846],
|
||||
# [14.75, 3.6414877020308386e-06, 3641.4877020308395],
|
||||
# [16.75, 1.973757599365769e-05, 19737.57599365769],
|
||||
[10.75, 1.1670056689678455e-08, 1.1731466540816526],
|
||||
# [14.75, 3.6414877020308386e-06, 474.36376505412574],
|
||||
# [16.75, 1.973757599365769e-05, 2850.6219623225024],
|
||||
]
|
||||
)
|
||||
def test_short_range_model(
|
||||
|
|
|
|||
Loading…
Reference in a new issue