# Epidemic SIR simulator for R0, vaccination, lethality, and transmission curves
This epidemic SIR simulator lets you explore how a pathogen spreads through a population when susceptible people become infected and then leave the infectious group through recovery or death. It is designed for students, science communicators, public health learners, and anyone who wants a fast visual explanation of why small changes in transmission or immunity can reshape an outbreak.The interactive controls focus on the variables people most often want to test: R0, lethality, vaccination coverage, vaccine effectiveness, infectious duration, and the initial infected share. The chart updates immediately so the susceptible, infected, recovered, immune, and death curves can be compared as one connected epidemic system.# How the SIR model works
A basic SIR model divides the population into three main compartments. S is susceptible people who can still become infected. I is currently infectious people who can transmit the pathogen. R is people who are no longer infectious because they recovered, gained immunity, or otherwise left the transmission chain. This simulator also tracks estimated deaths as a severe-outcome branch from the group leaving infection.The transmission rate is linked to R0 and the infectious period. If R0 is high or people remain infectious for longer, more new infections are generated before the infected group shrinks. If vaccination removes enough people from the susceptible pool, the effective reproduction number falls and the outbreak peak can become much smaller.| Control | What it changes | Typical curve effect |
|---|---|---|
| R0 | Transmission potential before immunity is considered | Higher R0 makes the infected curve rise faster and peak higher. |
| Vaccination coverage | Share of people moved out of the susceptible pool when protected | Higher coverage lowers Re and can flatten the outbreak. |
| Vaccine effectiveness | How much vaccination prevents infection in this simplified model | Higher effectiveness makes the same coverage more protective. |
| Infectious period | Average time people remain infectious | Longer infection changes timing and can prolong the outbreak. |
| Lethality | Share of people leaving infection who are counted as deaths | Higher lethality raises the death curve without directly increasing transmission. |
# R0, Re, and herd immunity intuition
R0 is the average number of secondary cases caused by one infectious person in a fully susceptible population. Re, the effective reproduction number, is lower when some people are already immune, vaccinated, isolated, or otherwise not available for infection. In this simulator, effective vaccination directly reduces susceptibility, so the displayed Re falls as protected coverage rises.A common herd-immunity approximation is 1 - 1 / R0. For an R0 of 3, the threshold is about 66.7% effective immunity. The simulator helps make that threshold tangible: when effective vaccination is below the threshold, outbreaks can still grow; when it is above the threshold, transmission struggles to maintain itself.# What the peak infected number means
Peak infected is the maximum number of people simultaneously infectious in the simulated population. It is often more operationally important than total infections because hospitals, laboratories, isolation programs, and contact tracing teams experience pressure from simultaneous active cases. Lowering the peak can matter even when the final attack rate is not reduced to zero.The attack rate estimates the share of the whole population infected by the end of the run. A high attack rate means the pathogen reached many people before susceptibility was depleted or controlled. A low attack rate means immunity, vaccination, or weak transmission prevented broad spread.# Real-world R0 values and what they imply for herd immunity
The basic reproduction number R0 is not a fixed biological constant for a pathogen. It depends on contact patterns, population density, cultural habits, and environmental factors. The same virus can have different R0 values in a dense city versus a rural area, or in a season with more indoor crowding. The values below are illustrative reference ranges from published studies.| Pathogen | Typical R0 range | Herd immunity threshold (1 - 1/R0) | Key transmission feature |
|---|---|---|---|
| Seasonal influenza | 1.2 - 1.4 | 17% - 29% | Short infectious period, seasonal variation |
| SARS-CoV-2 (ancestral) | 2.0 - 3.0 | 50% - 67% | Pre-symptomatic transmission, aerosol routes |
| SARS-CoV-2 (Delta) | 5.0 - 8.0 | 80% - 87% | Increased viral load, faster spread |
| SARS-CoV-2 (Omicron) | 8.0 - 12.0 | 87% - 92% | Immune evasion, upper respiratory tropism |
| Polio | 5.0 - 7.0 | 80% - 86% | Fecal-oral route, long asymptomatic shedding |
| Smallpox | 5.0 - 7.0 | 80% - 86% | Eradicated through global vaccination campaign |
| Measles | 12.0 - 18.0 | 92% - 94% | Extremely contagious, airborne, long infectious period |
| Pertussis (whooping cough) | 12.0 - 17.0 | 92% - 94% | Waning immunity allows repeat infections |
# How the effective reproduction number Re changes during an outbreak
Re is the effective reproduction number at a given point in the outbreak. Unlike R0, which assumes a fully susceptible population, Re accounts for immunity, vaccination, and any other factors that reduce susceptibility. In this simulator, Re is calculated as R0 x (1 - protected fraction), where the protected fraction is the share of the population effectively immune through vaccination.The Re value displayed in the simulator header updates as you move the controls. When Re stays above 1, the outbreak grows. When it falls below 1, each infected person generates fewer than one new infection on average, and the epidemic cannot sustain itself. This is the core insight behind epidemic control: bringing and keeping Re below 1 through immunity, behavior, or interventions.# Attack rate, peak burden, and what they reveal about outbreak severity
The attack rate is the fraction of the total population infected over the entire simulated outbreak. It is the most commonly cited summary metric after an epidemic wave. A high attack rate means the pathogen infected most susceptible people before depletion or control stopped transmission. A low attack rate means immunity, vaccination, or inherently weak transmission prevented widespread infection.Peak infected - the maximum number of people simultaneously infectious - matters more for short-term healthcare pressure. A wave with a moderate attack rate but a very high, sharp peak can overwhelm hospitals even if total cases are not extreme. Conversely, a slow, flattened curve can have a similar attack rate spread over many weeks, giving the health system time to manage cases. This is why public health officials emphasize flattening the curve as an operational goal distinct from preventing all infections.# Flattening the curve and healthcare capacity in the SIR model
The infected curve in an SIR model can be interpreted as the number of people requiring care simultaneously. In a real epidemic, each person who needs a hospital bed, oxygen support, or intensive care draws on a finite pool of resources. When the infected curve rises higher than the available capacity, mortality from all causes increases because the system cannot provide adequate care.Vaccination, in this model, flattens the curve by removing people from the susceptible pool before they can become infected. Reducing R0 through other measures - masks, ventilation, distancing, testing, isolation - would also lower the peak in a more complete model. The simulation makes the mechanism visible: as effective vaccination coverage increases, the peak shrinks, shifts later, or disappears entirely.# The mathematics behind the SIR model visualized
Under the SIR model, the rate of new infections per time step depends on three quantities: the transmission rate beta, the current number of infectious people I, and the fraction of the effective population that is still susceptible S / N. The product beta x I x S / N is called the force of infection. Each day, this force determines how many susceptible people move into the infected compartment.People leave the infected compartment at the recovery rate gamma = 1 / infectious period. The balance between the force of infection and the recovery rate determines whether the epidemic grows or shrinks. When beta x S / N exceeds gamma, new infections outpace recoveries and the outbreak expands. When the susceptible fraction S / N has fallen enough, gamma dominates and the outbreak contracts.The parameter beta is not directly visible in the interface. Instead, it is derived from R0 and the infectious period through the relation beta = R0 x gamma. This is why changing R0 or the infectious period produces similar but not identical curve shapes. Both parameters influence the force of infection, but the infectious period also stretches the time axis of the outbreak.# How to use this simulator for learning and teaching
- Compare high vs. low R0 scenarios: set R0 to 1.5 (seasonal flu range) and then to 6.0 (pre-vaccination polio range). Notice how the peak height, peak timing, and attack rate change even when all other controls are identical.
- Explore the herd immunity threshold: start with R0 at 3.0 and no vaccination. Note the attack rate. Then add vaccination coverage until Re falls below 1. Compare the peak and attack rate at coverage just below and just above the threshold.
- Test the effect of slow vs. fast response: set vaccination coverage at different levels and observe when the peak occurs. Higher coverage not only reduces the peak height but usually delays it, buying time for healthcare preparation.
- Separate lethality from transmission: set lethality to 0% and observe the infected curve. Then set lethality to 10% without changing other settings. The infected curve does not change, but the death toll rises. This demonstrates why case fatality rate and transmission speed are distinct epidemiological dimensions.
- Examine the infectious period effect: compare a 4-day infectious period against an 18-day period at the same R0. The longer period stretches the curve, delays the peak, and produces a longer but lower wave.
- Classroom exercise - find the threshold: ask students to find the minimum vaccination coverage that brings Re below 1 for a given R0, then compare the result to the formula 1 - 1/R0.
# When and why to use this simulator
- Epidemiology students: connect the mathematical SIR framework to interactive curve shapes before working with differential equations or programming their own models.
- Science communicators and journalists: generate plots, screenshots, or live explanations showing why R0, vaccination, and infectious period matter for outbreak trajectories.
- Public health learners: test how different intervention combinations shift the epidemic peak and attack rate to develop intuition about the trade-offs in outbreak response.
- Anyone curious about epidemic math: explore the SIR model without needing to write code or install software. Every control updates the chart in real time.