Stochastic SIR Epidemic — Gillespie Exact SSA

Exact stochastic simulation of disease spread with demographic noise

The Gillespie Stochastic Simulation Algorithm (SSA) generates exact trajectories of the master equation governing SIR epidemics. Unlike ODE models, SSA captures demographic stochasticity: with small N, epidemics can go extinct stochastically below R₀ = 1 threshold. Two reactions: S+I → 2I at rate βSI/N, and I → R at rate γI. Time to next event is exponential with rate a₀ = βSI/N + γI.