Skip to content

Commit 616f211

Browse files
committed
FIX: Hand over time to trial of distance function
1 parent 7dd4bed commit 616f211

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

tutorial04.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import marimo
22

3-
__generated_with = "0.19.11"
3+
__generated_with = "0.20.0"
44
app = marimo.App(width="medium")
55

66

@@ -267,13 +267,12 @@ def distance_ICU(simulation, real_data):
267267
return np.sum(np.abs(real_ICU - sim_ICU))
268268

269269
def distance_Deaths(simulation, real_data):
270-
deaths_per_critical = 1
271270
real_Deaths = real_data['Deaths']
272271
sim = simulation['data']
273272
sim_Death = sim[1 + int(osecir.InfectionState.Dead), :]
274-
return 1/deaths_per_critical * np.sum(np.abs(real_Deaths - sim_Death))
273+
return np.sum(np.abs(real_Deaths - sim_Death))
275274

276-
distance = pyabc.AdaptiveAggregatedDistance([distance_ICU, distance_Deaths], adaptive=False, scale_function=pyabc.distance.mean)
275+
distance = pyabc.AdaptiveAggregatedDistance([distance_ICU, distance_Deaths], adaptive=False, scale_function=pyabc.distance.median)
277276
return (distance,)
278277

279278

@@ -313,7 +312,7 @@ def _(example_results):
313312

314313
@app.cell
315314
def _(distance, example_results, observation_data):
316-
distance(example_results, observation_data)
315+
distance(example_results, observation_data, t=-1)
317316
return
318317

319318

@@ -349,15 +348,15 @@ def _(mo):
349348

350349
@app.cell
351350
def _(distance, observation_data, os, prior, pyabc, run_simulation, tempfile):
352-
abc = pyabc.ABCSMC(run_simulation, prior, distance, population_size=400, sampler=pyabc.sampler.SingleCoreSampler())
351+
abc = pyabc.ABCSMC(run_simulation, prior, distance, population_size=400)
353352
db_path = "sqlite:///" + os.path.join(tempfile.gettempdir(), "tmp.db")
354353
abc.new(db_path, observation_data)
355354
return (abc,)
356355

357356

358357
@app.cell
359358
def _(abc):
360-
history = abc.run(minimum_epsilon=1e-03)
359+
history = abc.run(minimum_epsilon=5e-01)
361360
return (history,)
362361

363362

tutorial06.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import marimo
22

3-
__generated_with = "0.19.11"
3+
__generated_with = "0.20.0"
44
app = marimo.App(width="medium")
55

66

@@ -417,7 +417,7 @@ def _(example_results):
417417

418418
@app.cell
419419
def _(distance, example_results, observation_data):
420-
distance(example_results, observation_data)
420+
distance(example_results, observation_data, t=-1)
421421
return
422422

423423

@@ -460,14 +460,14 @@ def _(distance, observation_data, os, prior, pyabc, run_simulation, tempfile):
460460

461461
@app.cell
462462
def _(abc):
463-
history = abc.run(minimum_epsilon=1)
463+
history = abc.run(minimum_epsilon=8e-1)
464464
return (history,)
465465

466466

467467
@app.cell(hide_code=True)
468468
def _(mo):
469469
mo.md(r"""
470-
Great, that worked out well. Let's take a look at the evaluation figures by `pyabc`. Here we can see the posterior distributions for the different parameters.Rendering the figure takes a few seconds.
470+
Great, that worked out well. Let's take a look at the evaluation figures by `pyabc`. Here we can see the posterior distributions for the different parameters. Rendering the figure takes a few seconds.
471471
""")
472472
return
473473

0 commit comments

Comments
 (0)