epiworldjs
Agent-based epidemic models from epiworld, running in your browser with WebAssembly. No server: each simulation runs on this page.
Playground
Pick any of the 17 models and move the sliders; the model re-runs as you go. Lines are medians across simulations, and bands cover 95% of them. Click a state in the legend to hide it.
Embed a model
One script tag and one element, in plain HTML, Quarto, R Markdown, or a CMS.
controls chooses which sliders to show, by epiworld's parameter names.
The script comes from the npm package
through jsDelivr; add a version to pin it (epiworldjs@0.18.0-0).
<script type="module"
src="https://cdn.jsdelivr.net/npm/epiworldjs/dist/epiworld-model.js"></script>
<epiworld-model model="MeaslesSchool" nsims="50"
params='{"Vaccination rate": 0.8, "Quarantine willingness": 0}'
controls="Vaccination rate, Quarantine willingness"
hide="Susceptible, Recovered, Quarantined Susceptible, Quarantined Recovered, Isolated Recovered"
autorun live></epiworld-model>
A school of 500 with one measles case. Without quarantine, an outbreak takes off; move Quarantine willingness up and watch the outbreak size fall.
JavaScript API
For your own plots, run models directly. Simulations are split across Web Workers,
and the results are the same for any number of workers. With a bundler or in Node,
npm install epiworldjs and import { Epiworld } from "epiworldjs".
import { Epiworld } from "https://cdn.jsdelivr.net/npm/epiworldjs/dist/epiworld-model.js";
const ew = await Epiworld.load();
const res = await ew.run({
model: "SIRCONN", n: 10000, ndays: 100, nsims: 50, seed: 1,
params: { "Contact rate": 4, "Transmission rate": 0.1 },
});
res.summary(); // median and 95% band per state and day
res.toCSV(); // epiworld's total_hist table
Every element also fires an epiworld-result event with the
Result, so pages can react to runs.