The Gillespie stochastic simulation algorithm is a Monte Carlo algorithm that simulates the time evolution of a chemical system according to its chemical master equation. In this demonstration, the reaction is simulated with variable forward and backward rate constants and initial particle numbers. The demonstration shows the key steps of the Gillespie method. In the top left, the time until the next reaction is drawn from an exponential distribution. In the bottom left, the next reaction step (forward or backward) is randomly chosen based on the propensities of reaction. The plot on the right shows the timecourse of each species . Use the "reaction event" slider to scroll through in time through the reactions that occur.
Contributed by: Oliver K. Ernst
Snapshot 1: sample forward reaction step in the Gillespie algorithm.
Snapshot 2: sample backward reaction step in the Gillespie algorithm.
Snapshot 3: the reaction system tends toward equilibrium.
The chemical master equation describes the time evolution of the probability distribution of possible states that describe the system. The Gillespie algorithm simulates a single trajectory of the state of the system which represents a sample from the probability distribution at each timepoint. In this demonstration, the reaction is considered to show the key steps of the algorithm. For further details on the Gillespie method, see [1,2].
 D. Gillespie, "Exact Stochastic Simulation of Coupled Chemical Reactions," The Journal of Physical Chemistry, 81(25),1977 pp. 2340-2361.
 D. Gillespie, "A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions," Journal of Computational Physics, 22(4), 1976 pp. 403-434.