lotka_volterra.py

Created by vnap0v

Created on September 11, 2025

1.88 KB

Lotka–Volterra predator–prey model

This script calculates and plots a solution to the predator–prey model.

It uses a simple Euler method, values are stored in numpy arrays for memory efficiency.

Lotka–Volterra system is defined by two first order ODEs:

dx/dt = alpha.x - beta.x.y   

dy/dt = -gamma*y + delta.x.y 
  • x is the prey population
  • y is the predator population density
  • alpha is the maximum prey per capita growth rate
  • beta is the effect of the presence of predators on the prey death rate
  • gamma is the predator’s per capita death rate
  • delta is the effect of the presence of prey on the predator’s growth rate

The script imports numpy and matplotlib.


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.