ExamplesEcology: Lotka–Volterra

Ecology: Lotka–Volterra

The classic predator–prey oscillator. Prey grow on their own, predators decline without food, and chance encounters couple the two populations into the canonical boom-bust cycle.

What it simulates

  • Prey reproduce when predators are scarce.
  • Predator–prey encounters reduce prey and feed predator reproduction.
  • Predators decline without prey.
  • The system circles a non-zero equilibrium at N* = gamma/delta, P* = alpha/beta.
  • An invariant-drift audit checks that the numerical integrator is faithful to the conserved quantity.

Lotka-Volterra population trajectories and phase portrait

Run it on the Hub

  1. Open the Lotka–Volterra System Lab on the public Hub.
  2. Click Run. The default scenario runs for 250 days.

Inputs you can tune

InputMeaning
prey_initial_populationStarting prey count.
predator_initial_populationStarting predator count.
prey_growth_ratePrey growth in the absence of predators.
predation_rateHow strongly predator–prey encounters reduce prey.
predator_mortality_ratePredator decline without prey.
predator_reproduction_rateHow prey encounters add to predators.

What results to expect

  • Population trajectory: lagged predator–prey oscillations.
  • Phase portrait: a closed loop around the non-zero equilibrium, with start/end markers and the dN/dt = 0 and dP/dt = 0 nullclines.
  • Summary table: parameters, equilibrium, final populations, min/max ranges, and an estimated cycle period.
  • Invariant-drift audit: a numerical-quality check; large drift means the integration step is too coarse.

Lotka-Volterra summary table and invariant drift diagnostics

Source on GitHub: models-ecology — lotka-volterra-system. For carrying capacity, seasons, disease, or migration, use the Rosenzweig–MacArthur lab instead.