Chemistry is discrete: molecules come in whole numbers and react at random instants. The Stochastic Simulation Algorithm draws each waiting time from an exponential set by the propensity a = k·n, fires one reaction, and repeats — an exact sample of the chemical master equation, not an approximation of it. Down the center, data flows: the state goes in, the SSA steps time forward, and the trajectory comes out. The blue team builds and defends it; the red team tries to break it.
source D. T. Gillespie, Exact Stochastic Simulation of Coupled Chemical Reactions, J. Phys. Chem. 81(25), 2340–2361 (1977) — doi:10.1021/j100540a008. Rendered, not quoted.
One channel: A → ∅ with rate constant k. Gillespie's direct method repeats four moves until nothing is left:
M1 compute the propensity a = k·n (n = molecules of A). M2 draw a uniform u ∈ (0,1] and set the waiting time τ = (1/a)·ln(1/u) — exponential with rate a. M3 pick which reaction fires (with one channel, always this one). M4 advance t ← t+τ, apply the reaction n ← n−1.
Live trace of the first four steps for the current n₀, k:
| step | n | a = k·n | τ drawn |
|---|
Take the same channel to the continuum limit and the count becomes a concentration obeying the mass-action rate law dn/dt = −k·n, whose solution is the smooth decay n₀·e^(−k·t).
That curve is exactly the ensemble mean of the SSA over many runs — the discrete-molecule twin of the mass-action law. The SSA draws its reaction times from those propensities; average enough trajectories and the noise cancels back into the ODE. Each sphere is the next one's premise.
The blue team's live check: re-draw thousands of waiting times and confirm the exponential's fingerprint — coefficient of variation = 1 (std/mean) — and confirm the ensemble mean still lands on n₀·e^(−k·t). If red tampers, this badge is where it shows.
The SSA needs only three inputs and a stream of uniforms:
| symbol | meaning | role |
|---|---|---|
| n₀ | initial molecules of A | state |
| k | per-molecule rate constant | propensity |
| u | uniform draws (fixed seed) | randomness |
The propensity a = k·n is the only physics; everything downstream is a consequence of it and the exponential clock. A fixed-seed PRNG (mulberry32) makes every run reproducible — the self-check is deterministic.
Exponential clock: τ = (1/a)·ln(1/u). Each run is a real, reproducible SSA sample.
Change any control — the trajectory, the ensemble mean and the deterministic curve are recomputed live from a = k·n, never looked up. Purple = exact ODE n₀·e^(−k·t); cyan = one SSA run; green dots = mean over the ensemble.
What the machine proves, live: the inter-event waiting time is exponential (mean ≈ 1/a and std ≈ 1/a, so CV = 1); every propensity is non-negative and every step strictly positive; and the ensemble mean of n(t) lands on the deterministic decay n₀·e^(−k·t). Discrete twin, continuous mean.
The blue team's witness (left) re-draws and confirms these numbers live; the red team (right) tries to make them wrong.
And the model is well-mixed and Markovian by assumption: no space, no diffusion, no memory. Real cells are none of those. The SSA is exact for the master equation it samples — which is itself a model, not the molecule.
"Gillespie invented stochastic chemical kinetics." Cut. Delbrück, Doob (1945) and Kendall built the theory; Gillespie gave the exact, physically-derived simulation algorithm — and the reason it is exact.
"The SSA is an approximation of the ODE." Cut. It is exact: it samples true trajectories of the chemical master equation. The ODE is the approximation — the mean of the SSA.
"Stochastic just means a noisy version of the rate law." Kept, corrected. The mean tracks the ODE, but the variance is real — near extinction and small counts the discreteness changes the biology.
The red team's move: replace the exponential draw with a constant τ = 1/a — right mean, zero variance. The average still looks fine; the fluctuations vanish. The blue team's witness (window 7) is watching the CV.
Freeze the clock to its mean and the coefficient of variation collapses from 1 to 0 — the witness re-draws, sees CV ≈ 0, and turns red. Nothing is faked; the attack is real and it is caught.