You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multinomial mode: initial conditions rounded per compartment, totals not conserved, seeds below one vanish #557
Population.initialize_compartments() applies stochastic_rounding() to each compartment independently. Consequences:
Totals no longer match the characteristics in the databook (a population of 1000 split 60/40 across two compartments can initialise to 999 or 1001).
Any compartment initialised below one person is usually rounded to zero. With the SIR demo scaled to ten people, the deterministic model keeps a fraction of an infection alive while every one of 300 stochastic runs went extinct. Users who scale down a model to explore small-population behaviour will see silent extinction with no warning.
Implementation plan
Round so that totals are preserved: compute the deterministic solution x, round the population total with stochastic_rounding, then allocate it across compartments with rng.multinomial(total, x / x.sum()). For frameworks with multiple population types or disconnected characteristic groups, do this per connected group of the initialisation system.
Emit a logger.warning when any compartment's deterministic initial value is between 0 and 1 in multinomial mode, naming the compartment, since this is the seed-infection case.
Add a test on the SIR demo that the initial total matches the databook exactly and that the warning fires when the infected seed is below one.
Activity