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

WIP - Stochastic Logistic Growth (ABC Toy problem) #1025

Merged
merged 32 commits into from
Jan 26, 2021

Conversation

jarthur36
Copy link
Contributor

Adds the spatially implicit birth-only logistic growth model (Simpson et al., 2019) to pints. Simulated using the interpretation of the Gillespie algorithm from (Erban et al., 2007)

This version is work in progress as the empirical mean of n stochastic runs does not converge to the deterministic mean as n->∞ as shown below
MeanDifference

Copy link
Contributor Author

@jarthur36 jarthur36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial self-review

pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 3, 2019

Codecov Report

Merging #1025 (af3262e) into master (a571e8b) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1025   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           83        84    +1     
  Lines         8730      8799   +69     
=========================================
+ Hits          8730      8799   +69     
Impacted Files Coverage Δ
pints/toy/_hes1_michaelis_menten.py 100.00% <ø> (ø)
pints/toy/__init__.py 100.00% <100.00%> (ø)
pints/toy/_stochastic_logistic_model.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a571e8b...af3262e. Read the comment docs.

@ben18785 ben18785 self-requested a review March 10, 2020 17:11
Copy link
Collaborator

@ben18785 ben18785 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jarthur36 Looking good. Thanks. If you look through my and @MichaelClerx 's comments here, and make these few changes, then we can get it merged.

  • Can we add a full references to the notebook? I.e. Simpson et al. and Gillespie et al. should be given in full at the bottom of the first block of text.
  • Can we add a reference to Radek Erban's book please? This was our main reference for the Gillespie algorithm.
  • In the example noetbook, at the moment, we aren't converging on the deterministic mean? Can we either change the text or up the number of particles so that we do?
  • We need value-based tests of the stochastic degradation model outputs? @MichaelClerx suggests we do this by seeding the random number generator, which sounds reasonable.
  • We need docstrings for the class itself.

pints/toy/_stochastic_logistic_model.py Show resolved Hide resolved
@chonlei
Copy link
Member

chonlei commented Nov 26, 2020

Just found out why there was the discrepancy between the deterministic model and the 1000-realisation average. Long in short, it all depends on the choice of parameters (in particular the initial size of the population)!

With the parameters that Jack used, the population was small, so each step gave a big variation, so it had a large 'noise'. Although we thought by running more simulations it'd converge to the deterministic solution, it'd not be the case when the initial population size is small (with some quick experiments, seems like n_0 > 10 would be a reasonable size, but needs some proper sensitivity anaylsis to give a better estimate). The reason seems to be that with a small initial population, the big noise at the beginning can drift (or shift?) the whole process (e.g., to delay the growth at a later time), then the 'time point-wise' average from these shifted solutions would give a bias.

So a simple fix to that is simply scaling up the whole population which solves the bias seen in the plot above, see below:

image
image

Copy link
Collaborator

@ben18785 ben18785 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chonlei -- looks really good. Only a few minor comments then fine to go.

Just wondering -- did you see #1067 ? This was Jack's attempt to create a more generic stochastic simulation approach (basically it should automate the Gillespie algorithm for many types of stochastic reaction equation). I just remembered it, sorry. Do you think merge this then later someone tries to adapt it to fit into such a framework?

pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/tests/test_toy_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Outdated Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Show resolved Hide resolved
pints/toy/_stochastic_logistic_model.py Show resolved Hide resolved
@chonlei
Copy link
Member

chonlei commented Dec 7, 2020

Just wondering -- did you see #1067 ? This was Jack's attempt to create a more generic stochastic simulation approach (basically it should automate the Gillespie algorithm for many types of stochastic reaction equation). I just remembered it, sorry. Do you think merge this then later someone tries to adapt it to fit into such a framework?

Think I would go for merging this first then adapt it to fit into a better framework later, since we've been quite slow on SDE and/or ABC...

Copy link
Member

@MichaelClerx MichaelClerx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chonlei and @jarthur36 !

Two tiny comments now, happy for this to be merged without further review once they're done

Copy link
Collaborator

@ben18785 ben18785 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chonlei happy for this to go in now (after tests complete). I'm not sure why the "build-and-test" check isn't executing?

@ben18785
Copy link
Collaborator

@MichaelClerx Any idea why the "build-and-test" thing isn't running?

@MichaelClerx
Copy link
Member

@MichaelClerx Any idea why the "build-and-test" thing isn't running?

I think that's an old test name that no longer exist. Will investigate!

@MichaelClerx MichaelClerx merged commit 8743814 into master Jan 26, 2021
@MichaelClerx MichaelClerx deleted the 890-stochastic-logistic-toy-model branch January 26, 2021 17:30
@MichaelClerx MichaelClerx mentioned this pull request Jan 26, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants