HomeMedicine & BiophysicsPrevalence Bathtub: Closed-Form ODE Companion (2D)

Prevalence Bathtub: Closed-Form ODE Companion (2D)

A 2D companion to the 3D prevalence-pool simulator: instead of tracking individual stochastic cases, this version integrates the bathtub stock-flow equation dP/dt = Incidence − P/Duration directly with RK4 and checks it live against the exact closed-form solution, exposing the same Incidence × Duration steady state from a genuinely different, deterministic angle.

Medicine & Biophysics2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-epidemiology ↗ Open standalone

The 3D prevalence tank tracks individual stochastic cases, each one resolving at random after a memoryless illness duration — an agent-based Monte-Carlo view of the same "bathtub" identity every epidemiologist learns: Prevalence ≈ Incidence × Duration. This 2D companion asks the same question from the opposite direction, at the population level: it integrates the stock-flow differential equation dP/dt = Incidence − P/Duration directly with a 4th-order Runge–Kutta stepper, and continuously checks that numeric integration against the equation's own exact closed-form solution, so you can watch two genuinely different computational methods — one stochastic and discrete, one deterministic and continuous — settle on the identical steady state. The tank's water level is the literal value of P(t); its two outflow spouts emit particles at the true instantaneous recovery and death rates, not merely for decoration.

⚙ Under the hood

A 2D companion to the 3D prevalence-pool simulator: instead of tracking individual stochastic cases, this version integrates the bathtub stock-flow equation dP/dt = Incidence − P/Duration directly with RK4 and checks it live against the exact closed-form solution, exposing the same Incidence × Duration steady state from a genuinely different, deterministic angle.

epidemiologyprevalenceincidencepublic healthbiostatisticscase-fatalitydifferential equationsODE

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)