Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Births - implementation can result in a step change in effective birth rate at 1-year intervals #4

Open
KevinMcCarthyAtIDM opened this issue Dec 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@KevinMcCarthyAtIDM
Copy link
Collaborator

Brought over births.py from laser measles, and noted that it's an implementation of births that draws a number of births for the year, and then distributes them pretty much uniformly by day. This gets the aggregate noise structure right, but imposes really strong temporal correlations in noise. Probably a small effect, but as long as this draw step is not a major contributor to runtime, I think there are options to do better.
E.g., In year 1 & year 2, we randomly draw a Poisson # for the annual births.
if doy == 1: model.patches.births[year, :] = model.prng.poisson(model.patches.populations[tick, :] * model.params.cbr / 1000)
Let's say that the mean is 1000 births, and so the std dev. is sqrt(1000) ~33.
It's a reasonable outcome to draw, say, 950 for the first year and 1050 for the second year, with that std. dev. And that's fine, that is within the expected variance of year to year births. We then distribute these as evenly as possible throughout the year
todays_births = (annual_births * doy // 365) - (annual_births * (doy - 1) // 365)

Again, nothing is strictly "wrong" - the sum of N Poisson variables with rate parameter lambda/N is strictly equal to a 1 Poisson variable with rate parameter lambda, so it is exactly equally likely to get one year with 950 births and 1 year with 1050 drawing 730 days vs. 2 years. But the even distribution of births impose a step change on the average birth rate that happens at 1-year intervals, and there may be situations where this correlation ends up with odd results. So I wonder about finding a clean way to "noise up" the births appropriately at sub-year intervals.

Compared to the model running, drawing births for each day is not that expensive for sims of reasonable nticks*npatches. There may also be ways to draw the number of births for the year but don't necessarily distribute them perfectly evenly throughout the year.

Again, probably a small effect but always looking for places to improve fidelity without too much impact on overall performance.

@KevinMcCarthyAtIDM KevinMcCarthyAtIDM added the enhancement New feature or request label Dec 6, 2024
@clorton
Copy link
Contributor

clorton commented Dec 6, 2024

The Poisson draw each year is trivial. Let’s discuss some more distributing those births daily with some noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants