◄ WORLD II · THE FOLDTHE OCHO · blue builds │ the machine │ red breaks

THE GILLESPIE ALGORITHM

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.

◧ blue team · builds & defends
3

THE MODEL — the SSA step

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:

stepna = k·nτ drawn
5

THE LINEAGE — the deterministic twin AVAN

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.

7

THE WITNESS live

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 machine ▼
4

DATA IN — the state in ↓

The SSA needs only three inputs and a stream of uniforms:

symbolmeaningrole
n₀initial molecules of Astate
kper-molecule rate constantpropensity
uuniform 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.

▼   feed the state into the engine   ▼
0

▣ THE PANEL — the engine LIT

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.

▼   the engine emits a trajectory   ▼
8

DATA OUT — the result out ↓

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.

red team · attacks & breaks ◨
1

THE ADVERSARY

WALL Exact does not mean cheap. The SSA steps one reaction at a time — a fast or large system fires astronomically many events, so cost scales with the number of reactions, not the timespan. τ-leaping and the deterministic ODE buy speed by giving up exactness.

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.

2

THE GRAVEYARD

"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.

6

THE TAMPER — break it

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.