REGIR: A Scalable Gillespie Algorithm for non-Markovian Stochastic Simulations
Refer to the github folder for a full description (https://github.com/Aurelien-Pelissier/REGIR). Discrete stochastic processes are widespread in both nature and human-made systems, with applications across physics, biochemistry, epidemiology, social patterns and finance, just to name a few. In the majority of these systems, the dynamics cannot be properly described with memoryless (or Markovian) interactions, and thus require the use of numerical tools for analyzing these non-Markovian dynamics. This repository contains an implementattion of a general and scalable framework to simulate non-Markovian stochastic systems with arbitrary inter-event time distribution and accuracy. The algorithm is referred to as the Rejection Gillespie algorithm for non-Markovian Reactions (REGIR) [1].
Simulating a non-Markovian system
First, you need to install REGIR, or you can use the REGIR.py file provided in the repository:
- pip install REGIR
Then, you can directly run a non-Markovian simulation with this toy example (other examples, including the three biochemical systems described in the paper: Cell division, differentiation and RNA transcription, are provided in the /REGIR/Examples folder.):
import REGIR as gil
#Set the simulation parameters:
class param:
Tend = 10 #Length of the simulation
N_simulations = 20 #The simulation results should be averaged over many trials
unit = 'h' #Unit of time (used for plotting only)
timepoints = 100 #Number of timepoints to record (used for plotting only)
r1 = 1
r2 = 4
r3 = 0.03
alpha1 = 20
alpha2 = 5
#Define the reaction chanels:
reaction1 = gil.Reaction_channel(param,rate=r1, shape_param=alpha1, distribution = 'Gamma')
reaction1.reactants = ['A']
reaction1.products = ['B']
reaction2 = gil.Reaction_channel(param,rate=r2, shape_param=alpha2, distribution = 'Weibull')
reaction2.reactants = ['B']
reaction2.products = ['C','A']
reaction3 = gil.Reaction_channel(param,rate=r3)
reaction3.reactants = ['A','B']
reaction3.products = []
#Define the initial population of reactants:
N_init = dict()
N_init['A'] = 300
N_init['B'] = 0
N_init['C'] = 0
#Initialize and run the Gillepsie simulation:
reaction_channel_list = [reaction1, reaction2, reaction3]
G_simul = gil.Gillespie_simulation(N_init,param)
G_simul.reaction_channel_list = reaction_channel_list
G_simul.run_simulations(param.Tend, verbose = True)
G_simul.plot_inter_event_time_distribution()
G_simul.plot_populations()
The algorithm runs for a few seconds and output the following figures (note that you can disables all printing and plotting by passing the argument verbose = False when running the simulation)
Implemented distributions
With the current implementation, each available distribution are characterised by their rate and a shape parameter as follow:
Exponential:
- rate: 1/mean
- shape parameter: None
Normal:
- rate: 1/mean
- shape: std/mean
LogNormal:
- rate: 1/mean
- shape: std/mean
Gamma:
- rate: 1/mean
- shape: α >= 1 (https://en.wikipedia.org/wiki/Gamma_distribution)
Weibull:
- rate: 1/mean
- shape: k >= 1 (https://en.wikipedia.org/wiki/Weibull_distribution)
Cauchy:
- rate: 1/median
- shape: γ (https://en.wikipedia.org/wiki/Cauchy_distribution)
Keep in mind that non-Markovian simulations are only available for reaction channels with a single reactant, as the definition of inter-event time distribution is ambigious for channels with multiple reactants. If a channel is defined without or with more than one reactant, it will be considered as a Poisson process. Also, note that monotolically decreasing distributions, such as Weibull (k < 1), gamma (α < 1) or power laws, are not available in the current implementation of this repository, as these can be more elegantly and efficiently simulated with the Laplace Gillespie algorithm [2].
Feel free to drop me an email if you have interest in me adding the Laplace Gillespie or any other relevant distributions to this implementation.
References
[1] Pelissier, A, Phan, M, et al. "Practical and scalable simulations of non-Markovian stochastic processes". Proceedings of the National Academy of Sciences (2022)
[2] Masuda, Naoki, and Luis EC Rocha. "A Gillespie algorithm for non-Markovian stochastic processes." Siam Review 60.1 (2018): 95-115.
Metadata
Release files for REGIR 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| REGIR-1.0.5.tar.gz | 13.7 kB | Without provenance | Details for REGIR-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| REGIR-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for REGIR-1.0.5-py3-none-any.whl |
Total release size: 26.0 kB
Release files / REGIR-1.0.5.tar.gz
| Download URL | REGIR-1.0.5.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0450cf2cabf05689da1c0c011ea5308533eff4e6bb1aeaa0bea09a57851908c6
|
|
BLAKE2b-256 checksum How to use checksums |
64b63cf907a8dd3ba24a3f170638dffb89fa97171ea234f6722c4ab9be2d2e33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/3.7.3 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / REGIR-1.0.5-py3-none-any.whl
| Download URL | REGIR-1.0.5-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40fd5033320986e0e023bb1fe4562f771bd23d9c4b6c26a15934bf2ac004b75b
|
|
BLAKE2b-256 checksum How to use checksums |
72a4c291cb1d0e02f11037dd52ff80d011cf72e189eb18107ad8a74224ccb301
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/3.7.3 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Security for REGIR 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.