Daniel T. Gillespie 2026-11-05
Daniel T. Gillespie developed stochastic simulation methods for reacting molecular populations. In the Gillespie algorithm, a reaction propensity function specifies an event rate, and the algorithm samples both the next reaction time and the reaction channel rather than evolving only mean concentrations.[ref]
If the total propensity is , the waiting time is exponentially distributed with rate , and channel is selected with probability at the current state. His tau-leaping approach groups reaction events to accelerate simulation, introducing a controlled approximation rather than retaining the exact event-by-event law.[ref]
Approximate accelerated stochastic simulation of chemically reacting systems by Daniel T. Gillespie. Leap condition and approximate grouped-reaction evolution
Gillespie algorithm Created 2026-09-28 Updated 2026-11-05
The Gillespie algorithm samples statistically exact trajectories of a well-mixed chemical reaction network modeled by a continuous-time Markov chain. At copy-number state , each reaction propensity function is a nonnegative event rate and each stoichiometric vector specifies the update. Assume the rates have no explicit time dependence. Put . If , no further chemical reaction can occur: the state is an absorbing state.
For , sample a waiting time from the exponential distribution with rate , independently choose channel with probability , and update . Recompute the reaction propensity functions and repeat. The no-event probability is because ; multiplying by gives the joint waiting-time/channel probability density function . This factorization explains the two draws.[ref]
Approximate accelerated stochastic simulation of chemically reacting systems by Daniel T. Gillespie. Section II, equations (5)–(9), review of the exact stochastic simulation algorithm
For with reaction propensity function , the waiting time has mean , and is an absorbing state. Exactness concerns the specified chemical master equation; spatial mixing errors and explicitly time-varying rates require a different model or sampling rule.
The Gillespie algorithm draws a waiting time with total event rate , then chooses infection with probability and recovery otherwise. Each event conserves , and is absorbing in this closed stochastic SIR model.
Choose a horizon of 100 days, which is longer than all extinction times in the runs reported here. This independent implementation also avoids executing a sampled event beyond the horizon:
import numpy as np
import matplotlib.pyplot as plt
EPIDEMIC_RNG = np.random.default_rng(2345)
def sir_sim(t_max,X0,beta,gamma,rng=None):
if rng is None:rng=EPIDEMIC_RNG
state=np.array(X0,dtype=int);population=state.sum();time=0.
times=[time];states=[state.copy()]
while time<t_max and state[1]>0:
infection=beta*state[0]*state[1]/population;recovery=gamma*state[1]
rate=infection+recovery
if rate==0:
times.append(float(t_max));states.append(state.copy());break
next_time=time+rng.exponential(1/rate)
if next_time>t_max:
times.append(float(t_max));states.append(state.copy());break
if rng.random()<infection/rate:state+=np.array([-1,1,0])
else:state+=np.array([0,-1,1])
time=next_time;times.append(time);states.append(state.copy())
return np.array(times),np.array(states)
rng = np.random.default_rng(2345)
trajectories = [sir_sim(100, [99,1,0], 1, .25, rng) for _ in range(10)]
for times, states in trajectories:
plt.step(times, states[:,1], where="post", alpha=.8)
plt.xlabel("Time (days)")
plt.ylabel("Infected individuals")
plt.show()A step plot represents the piecewise constant infected population between events. The trajectories show both substantial outbreaks and early epidemic extinction despite the large basic reproduction number .
Ten original stochastic SIR trajectories, with frequency-dependent transmission and one initial infection
. Details. Past exam of the mathematics course of the University of Cambridge 2007 iii Paper 74 2 c Solution Created 2026-10-03 Updated 2026-10-14
For the Gillespie algorithm, start from and an integer molecular copy number . At each step use the current state, without the mean approximation in parts (a)–(b). The reaction propensity functions are and , and their sum is . Draw two independent uniform random variables on and setThe waiting time has an exponential distribution with rate . Keep the sample path constant on , advance , and choose the reaction byRecord the post-jump state, recompute both reaction propensity functions, and repeat with fresh independent uniforms. At the death propensity is zero, so only a birth is selected and the trajectory remains nonnegative. For a prescribed terminal time , if the next event would occur after , keep the current state to and stop. This produces exact piecewise constant sample paths of the specified continuous-time Markov chain.
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 207 3 f Solution Created 2026-10-03 Updated 2026-10-06
For the stochastic SIR model, the state is a continuous-time Markov chain on nonnegative integer triples summing to , initially . Its only transitions areRates vanish when a proposed transition would leave the state space. Equivalently, with independent unit-rate Poisson processes , the Poisson time-change representation of a Markov chain isThe left limits describe the state immediately before each jump. In the Gillespie algorithm, wait an exponential distribution time with rate , then choose infection or recovery in proportion to these two rates.
Past exam of the mathematics course of the University of Cambridge 2022 iii Paper 356 2 e Solution 2026-09-28
An exact Gillespie algorithm for one particle is:
For , simulate particle identities independently and maintain a priority queue of their next event times. For , store occupation numbers and use aggregate event rates and for each well; one population-level Gillespie event then decrements one and increments its neighbor. This replaces work proportional to particle number by work proportional to the number of occupied wells.
Past exam of the mathematics course of the University of Cambridge 2023 iii Paper 356 3 e Solution 2026-09-28
1. At the current integer , compute and the averaged rates and .
2. Draw a waiting time .
3. Set with probability ; otherwise set .
4. Advance time by and repeat.
2. Draw a waiting time .
3. Set with probability ; otherwise set .
4. Advance time by and repeat.
This is a Gillespie algorithm for the averaged slow master equation. It samples the fast conditional equilibrium analytically through its factorial moment and never simulates individual fast births or deaths.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 356 1 a Solution 2026-09-28
Write the molecular copy numbers as and use the power-law reaction propensity convention of the paper. The seven propensities and stoichiometric vectors areA channel is assigned zero propensity whenever its update would leave the nonnegative integer lattice.
The Gillespie algorithm starts from and . At the current state compute . If , terminate the path. Otherwise draw independent random variables from the uniform distribution on , set the next waiting time toand choose the least index satisfyingThen update and , and repeat. The minimum of the seven competing reaction clocks has an exponential distribution of rate , while reaction wins with probability .
Slow-scale stochastic simulation algorithm Created 2026-09-28 Updated 2026-11-05
A slow-scale stochastic simulation algorithm applies the Gillespie algorithm to propensities averaged over fast conditional equilibrium, avoiding explicit simulation of every fast reaction.
Tau-leaping 2026-11-05
Tau-leaping accelerates the Gillespie algorithm by approximating reaction rates as constant over an interval , then drawing all reaction counts for that interval at once. At state , with reaction propensity functions and stoichiometric vectors , the explicit step isThe leap condition requires the propensities to change little during the interval. Unlike event-by-event exact simulation, this introduces an approximation error controlled through the choice of .[ref]
Approximate accelerated stochastic simulation of chemically reacting systems by Daniel T. Gillespie. Section III, Poisson tau-leap construction
For with rate , the approximate number converted is Poisson with mean . The exact number converted over the interval is instead binomial with parameters and . The two agree to first order for small , but the Poisson draw can exceed and produce a negative count. Smaller or adaptive leaps and modified sampling rules address this limitation; freezing the rate is not automatically safe at low copy number.
