Tutorials › Stochastic Processes › Why Gillespie Waiting Times and Event Choices Are Exact

Simulation of Stochastic Processes · Tutorial 992 of 994

Why Gillespie Waiting Times and Event Choices Are Exact

See why the Gillespie waiting-time formula and proportional event selection reproduce the exact competing-clock law at each state.

Intermediate 10 min read

What You'll Learn

  • Derive the distribution of the minimum of independent exponential clocks.
  • Prove that the first event label is selected in proportion to its rate.
  • Show that the waiting time and event label are independent.
  • Translate state-dependent propensities into the Gillespie direct method.
  • Handle zero-rate channels and states with no possible events.
  • Identify a common incorrect way to combine event selection and waiting times.

Why a Single Waiting Time and One Event Choice Work

In a continuous-time reaction system, several events may be possible at the same state. Each has its own rate, or propensity, and the next change is whichever event happens first. Gillespie’s direct method replaces this collection of competing clocks with one waiting-time draw and one event-choice draw. The method is exact because those two draws reproduce the joint distribution of the first clock to ring and its event label.

Let \((\Omega,\mathcal{F},\mathbb{P})\) be a probability space and let \((X_t)_{t\ge 0}\) be a continuous-time process with state space \(S\), taken here to be finite or countable. At state \(x\), suppose there are finitely many event channels \(r\in\{1,\dots,m\}\). Channel \(r\) has propensity \(a_r(x)\ge 0\), and when it occurs it changes the state according to a specified rule \(\phi_r(x)\). Assume the propensities are finite. A channel with propensity zero cannot occur at that state. The total propensity is

$$ a_0(x)=\sum_{r=1}^{m}a_r(x). $$

For the moment, fix a state \(x\) and write \(a_r=a_r(x)\). Model each possible event by an independent exponential clock \(T_r\) with rate \(a_r\): for \(a_r>0\), \(\mathbb{P}(T_r>t)=e^{-a_rt}\) for \(t\ge 0\). A zero-rate clock is interpreted as \(T_r=\infty\). The next event time is \(T=\min_r T_r\), and its label is the index \(J\) of the first clock to ring.

Theorem (Competing exponential clocks): If \(a_0=\sum_{r=1}^m a_r>0\), then \(T\) is exponential with rate \(a_0\), and \(\mathbb{P}(J=r)=a_r/a_0\). Moreover, \(T\) and \(J\) are independent. Ties for the first event have probability zero. If \(a_0=0\), no event occurs.

Proof. Independence of the clocks gives, for \(t\ge 0\),

$$ \mathbb{P}(T>t)=\mathbb{P}(T_1>t,\ldots,T_m>t) =\prod_{r=1}^{m}e^{-a_rt} =e^{-a_0t}. $$

This is the survival function of an exponential random variable with rate \(a_0\). For any channel \(r\) with \(a_r>0\), the probability that its clock rings in a short interval from \(t\) to \(t+dt\), while all other clocks have not rung by time \(t\), has density \(a_re^{-a_0t}\). Thus the joint density of \(T\) and the event \(J=r\) is \(a_re^{-a_0t}\). Integrating over \(t\ge 0\) gives \(\mathbb{P}(J=r)=\int_0^\infty a_re^{-a_0t}\,dt=a_r/a_0\). Dividing the joint density by the density \(a_0e^{-a_0t}\) of \(T\) gives \(\mathbb{P}(J=r\mid T=t)=a_r/a_0\), which does not depend on \(t\); hence \(T\) and \(J\) are independent. A positive-rate exponential variable has a continuous distribution, so two positive-rate clocks tie with probability zero. A zero-rate clock never rings. Finally, if \(a_0=0\), every nonnegative \(a_r\) is zero, so all clocks equal infinity and no event occurs. \(\square\)

The theorem gives the direct-method step at state \(x\). If \(a_0(x)>0\), draw a uniform random variable \(U\) on \((0,1)\) and set \(\Delta t=-\log(U)/a_0(x)\). Separately choose channel \(r\) with probability \(a_r(x)/a_0(x)\), for example by partitioning the unit interval into consecutive intervals of those lengths. The waiting time and the event label must be generated independently. Then advance time by \(\Delta t\), apply \(\phi_r\), recompute propensities at the new state, and repeat. If \(a_0(x)=0\), the state has no possible event and the process remains there.

Worked Example: Two Clocks with Rates Two and Three

At a fixed state, suppose channel 1 has rate \(a_1=2\) and channel 2 has rate \(a_2=3\). The total rate is \(a_0=2+3=5\). The race theorem gives \(\mathbb{P}(T>t)=e^{-5t}\), so the mean waiting time is \(1/5\). The event probabilities are \(\mathbb{P}(J=1)=2/5\) and \(\mathbb{P}(J=2)=3/5\); they sum to \(2/5+3/5=1\).

The joint densities provide a further check. The density for channel 1 to be first at time \(t\) is \(2e^{-5t}\), and for channel 2 it is \(3e^{-5t}\). Their sum is \(5e^{-5t}\), the density of the waiting time. Integrating the first density gives \(\int_0^\infty 2e^{-5t}\,dt=2/5\), and integrating the second gives \(\int_0^\infty 3e^{-5t}\,dt=3/5\). Thus the separate event probabilities and the waiting-time distribution agree with the joint clock calculation.

For a direct-method draw, take \(U=1/2\) for the waiting-time draw. Then \(\Delta t=-\log(1/2)/5=\log(2)/5\). For the independent event-choice draw, take \(V=1/2\) and assign channel 1 to \([0,2/5)\) and channel 2 to \([2/5,1)\). Since \(1/2\ge 2/5\), the selected channel is 2. These particular draws illustrate the method; the theorem establishes its distributional exactness.

Why State-Dependent Propensities Preserve the Law

After an event, the state usually changes, so the propensities must be recalculated. The clock calculation applies conditionally at every state: given the current state \(x\), the next waiting time and event label have the law just derived using \(a_r(x)\). If fresh independent random draws are used after each event, this gives the same conditional evolution as restarting the competing clocks at the new state. In a reaction model with finite state space, this constructs the continuous-time Markov chain with the specified event rates. For countably many states, the same stepwise construction applies; to describe a process for all finite times, one also requires that infinitely many events do not accumulate in finite time.

Proposition (Rates of state changes): Suppose \(S\) is finite, all propensities are finite, and every positive-rate channel changes the state. For distinct states \(x,y\), define \(q_{xy}=\sum_{r:\phi_r(x)=y}a_r(x)\), and define \(q_{xx}=-\sum_{y\ne x}q_{xy}\). Then \(Q=(q_{xy})\) has rows summing to zero and gives the infinitesimal transition rates of the process.

Proof. Fix a state \(x\). There are finitely many states and channels, so the total rates are bounded above by some finite \(R\). In an interval of length \(h>0\), the probability of at least one event is \(1-e^{-a_0(x)h}=a_0(x)h+O(h^2)\), by the exponential expansion. The probability of two or more events is \(O(h^2)\): the probability of a first event is at most \(Rh\), and, conditional on its occurrence, the probability of another event within the remaining interval is at most \(Rh\); their product is at most \(R^2h^2\). Therefore, for \(y\ne x\), the probability of being at \(y\) at time \(h\), given state \(x\) at time zero, is the probability that a single event leading to \(y\) occurs, up to an error \(O(h^2)\). Summing the rates of those channels gives \(\mathbb{P}(X_h=y\mid X_0=x)=q_{xy}h+O(h^2)\). The probability of remaining at \(x\) is consequently \(1-\sum_{y\ne x}q_{xy}h+O(h^2)=1+q_{xx}h+O(h^2)\). These are the infinitesimal transition rates, and the definition of \(q_{xx}\) gives \(\sum_y q_{xy}=0\) for every row. \(\square\)

If a channel changes no state, it can still be simulated as a reaction event, but it is not a state change. In that case the total rate for the next reaction event includes that channel, while the off-diagonal generator rates include only channels that actually change the state. The proposition’s assumption excludes this distinction so that its total event rate is also the total state-change rate.

Worked Example: Recompute Rates After a State Change

Let the state be \((A,B)\), the counts of two species. At state \((2,1)\), channel 1 converts one \(A\) to one \(B\), with propensity \(a_1(A,B)=2A\). Channel 2 converts one \(B\) to one \(A\), with propensity \(a_2(A,B)=3B\). Substitution gives \(a_1(2,1)=2\cdot2=4\) and \(a_2(2,1)=3\cdot1=3\), so \(a_0(2,1)=4+3=7\). The waiting time is exponential with rate 7, and the event probabilities are \(4/7\) and \(3/7\), which sum to \(1\).

For example, use \(U=1/2\) for the time draw. Then \(\Delta t=-\log(1/2)/7=\log(2)/7\). Independently use \(V=5/7\) and assign channel 1 to \([0,4/7)\) and channel 2 to \([4/7,1)\). Since \(5/7\ge4/7\), channel 2 occurs. The new state is \((3,0)\): one \(B\) is converted to one \(A\). At this new state, the rates are \(2\cdot3=6\) and \(3\cdot0=0\), so the total is 6 and the next event, if simulated, must be channel 1. The event-choice probability for channel 1 is \(6/6=1\), and for channel 2 it is \(0/6=0\). This check shows why propensities are recalculated after each event rather than held at their initial values.

Worked Example: Two Channels with the Same Destination

At state \(x\), suppose channel 1 has rate \(1\), channel 2 has rate \(2\), and both lead to the same state \(y\). A third channel has rate \(3\) and leads to a different state \(z\). The total rate is \(1+2+3=6\), so the next reaction-event time is exponential with rate 6 and has mean \(1/6\). The probability that the next event leads to \(y\) is the sum of the probabilities of its two channels: \(1/6+2/6=3/6=1/2\). The probability it leads to \(z\) is \(3/6=1/2\). These destination probabilities sum to \(1/2+1/2=1\).

If the event label matters, the probability of channel 1 is \(1/6\), that of channel 2 is \(2/6\), and that of channel 3 is \(3/6\). Conditional on the next event leading to \(y\), the chance it was channel 1 is \((1/6)/(1/2)=1/3\), and the chance it was channel 2 is \((2/6)/(1/2)=2/3\); these conditional probabilities sum to \(1\). Thus one may track either the channel label or just the resulting state, but the event-choice probabilities must reflect the rates of all channels that produce the chosen outcome.

Exactness and a Common Mistake

Here, “exact” means that, conditional on the current state, the algorithm produces the same waiting-time and event-label distribution as the competing-clock model. It does not mean that a computer represents a continuous random number or a logarithm without numerical approximation. In a finite-state model, repeating the exact conditional step gives the intended continuous-time Markov chain. A simulation remains random: exactness concerns its probability law, not whether an individual simulated path matches a predetermined path.

Common mistake: choose an event first, then use that event’s rate for the waiting time. With rates \(1\) and \(3\), the event probabilities are \(1/4\) and \(3/4\), but the waiting time is exponential with total rate \(4\), regardless of which event wins. If one instead selects a channel first and then uses an exponential waiting time with that channel’s rate, the mean waiting time becomes \((1/4)(1)+(3/4)(1/3)=1/4+1/4=1/2\). The correct mean is \(1/4\), since the correct total rate is \(1+3=4\). Equivalently, the incorrect survival probability is the mixture \((1/4)e^{-t}+(3/4)e^{-3t}\), not the correct \(e^{-4t}\). The waiting time and event label are independent under the competing-clock law, but the waiting time is governed by the sum of the rates, not the selected channel’s rate.

The method also has a degenerate case that should not be forced through the formula. If all propensities at \(x\) are zero, then \(a_0(x)=0\), and dividing by \(a_0(x)\) is undefined. The correct interpretation is that no event can occur from \(x\); the state is absorbing under these event rules. If some but not all propensities are zero, the total is positive and the zero-rate channels receive event probability zero.

The practical check at each simulation step is therefore simple: add all current propensities; use that sum as the rate of one exponential waiting time; choose a channel with probability equal to its propensity divided by that same sum; then update the state and recompute. The clock proof explains why each part is required and why the resulting step is exact.

Check Your Understanding

Use the competing-clock calculation to justify each answer.

  1. At a state with three channels of rates \(2\), \(0\), and \(5\), what is the waiting-time distribution, and what is the probability of each channel being first?
  2. For two independent clocks with positive rates \(a_1\) and \(a_2\), derive \(\mathbb{P}(J=1)\) by integrating the joint density of the first time and its label.
  3. Why must the event-choice draw be independent of the waiting-time draw in the direct method?
  4. Two channels of rates \(2\) and \(4\) both lead to state \(y\), and another channel of rate \(6\) leads to \(z\). Find the total event rate and the probability the next event leads to \(y\).
  5. What should the algorithm do at a state where every propensity is zero, and why is the formula \(a_r/a_0\) not applicable there?