17. Ecology
[status: some-substance-but-incomplete]
17.1. Motivation, Prerequisites, Plan
As I write this, in April of 2020 at the start of a lockdown caused by the COVID19 virus, it seems like a good opportunity to get comfortable with some of the equations that come up when we talk about growth. We will look at the growth of a population, or growth of the number of infected humans (which is related to the growth of the population that carries the infection).
Ecology is a vast topic. Here we will look at population ecology, the study of how populations of a species or group change over time.
Let us start with this crash course video which discusses population ecology in general and uses the Texas nile virus “mystery” as an example.
You should also go through this very readable article on population growth from Nature.
Our plan for this chapter is to look at a single species with infinite food and no constraints (exponential growth), then at constrained growth and the logistic equation, and then we will move to the multi-species ecologies and examine predator-prey dynamics.
Note
We will make much use of differential equations, since they come up in discussion population dynamics. The examples in this chapter should be self-contained, but you will want to read the Differential Equations chapter for an overall introduction to the subject.
And the topics here can also be studied with agent based models which you can study in the chapter Basic agent-based modeling.
17.2. Factors that come up in modeling population ecology
name |
variable |
|
initial pop: |
P |
|
birth rate: |
B |
|
death rate: |
D |
|
growth rate: |
r |
= (B - D) / P |
predation |
||
immigration |
||
emigration |
||
mates |
||
food |
||
space |
17.3. Exponential growth
17.3.1. Unlimited
Spend some time plotting exponentials in gnuplot. Show how they dwarf linear growth, and how you need log scale to compare them.
The shift to looking at the differential equation for population growth. Note that this is also
The equation that represents population growth is:
This is studied in detail in Section 16.5, with solutions looking like
But if you could not solve it easily then you would write it out like this:
This can be demonstrated with a simple program that calculates:
P0 = 10
rate = 1.2
delta_t = 1
P = P0
print('## generation population')
for generation in range(100):
P = P + P * (rate-1) * delta_t
print(generation, ' ', P)
17.3.2. Resource-constrained - r-selection versus K-selection
- r-selection
A strategy in which you reproduce as quickly as you can.
- K-selection
A strategy in which you reproduce less and put more effort into your children.
17.3.2.1. Simulating with the logistic equation
The balance between these two is given by having large or small \(r\) or \(k\) in the logistic equation:
This can be solved with:
where
This can be visualized with a simple program:
#! /usr/bin/env python3
"""Prepare data with the solution to the logistic equation for various values
of r."""
import math
def main():
P0 = 30
delta_t = 0.01
print('# time P_bigr P_medr P_smallr')
for tstep in range(5000):
t = delta_t * tstep
P_0 = Plogistic(P0, t, 0.1, 500)
P_1 = Plogistic(P0, t, 0.25, 500)
P_2 = Plogistic(P0, t, 0.5, 500)
P_3 = Plogistic(P0, t, 0.75, 500)
P_4 = Plogistic(P0, t, 1.0, 500)
print(f'{t:<7g} {P_0:.7g} {P_1:7g} {P_2:7g} {P_3:7g} {P_4:7g}')
def Plogistic(P0, t, K, r):
"""Caluclates the logistic function as formulated by ecologists: P(t) =
K / (1 + (K-P0)/P0 * e^{-rt}). This solves the logistic equation dP/dt =
rP(1 - P/K), where r is the growth rate and K is the carrying capacity.
Note that in other contexts than ecology the letters used for growth rate
and carrying capacity are sometimes different. Here I used the convention
in
https://en.wikipedia.org/wiki/Logistic_function#In_ecology:_modeling_population_growth
"""
result = K / (1 + ((K-P0)/P0) * math.exp(-r*t))
return result
if __name__ == '__main__':
main()
$ python3 logistic_solution.py > rk.out
$ gnuplot
plot [] [0:500] 'rk.out' using 1:2 title 'r = 0.1'
replot 'rk.out' using 1:3
replot 'rk.out' using 1:4
replot 'rk.out' using 1:5
replot 'rk.out' using 1:6
17.4. History of the human population on earth
Let us take a tour of the history of human population on Earth. We can start by perusing the Wikipedia page on historical population estimates as well as this PRB data study on how many people have lived on Earth.
Also spend some time exploring the “Our World in Data” interactive graphs
Expand the title on “All our charts on World Population Growth”, and pick the population by country since 1500 and try to understand what areas are exponential.
Then look at the link “World population since 10,000 BCE (OurWorldInData series)”.
Download the data for this graph and zoom in on some specific periods. Look at both linear and logarithmic scales.
Following the indications shown in this Nature article we can look at the table below and seek certain interesting periods in the data.
Start |
End |
What to look for |
---|---|---|
-10000 |
-4000 |
Agricultural revolution |
-4000 |
-600 |
Early empires |
-1000 |
300 |
Alexander and Rome |
1 |
300 |
Imperial Rome |
1 |
1600 |
Largely steady world population |
1200 |
1400 |
Medieval black death |
1500 |
present |
Modern world |
1850 |
present |
Industrial revolution |
1900 |
present |
Large scale science |
Although the earth’s population as a whole appears to still be in an exponential growth phase, the Pew Research Center predicts that it will flatten by the end of the 21st century
This type of function is not exponential growth anymore: it shows exponential growth, but that then slows down and we end up with what is called the Logistic Function we have introduced.
17.5. Predator-prey systems and the Lotka-Volterra differential equations
The Lotka-Volterra equations describe how the populations of two species (where one is a predator to the other) change in time.
17.5.1. The equations
The equations are coupled first order ordinary differential equations and they look like this:
This system has two functions
- \({\bf x(t)}\)
population density of prey
- \({\bf y(t)}\)
population density of predator
and it has four coefficients:
- \(\alpha\)
per capita growth rate of prey
- \(\beta\)
effect of presence of predators on the prey death rate (how viciously do predators kill prey)
- \(\gamma\)
per capita death rate of predator
- \(\delta\)
effect of presence of prey on predator’s growth rate (how good are the prey as food)
You should look at these equations and try to understand how the various quantities interact to model the situation. A reasonable guide is the wikipedia discussion of the biological interpretation (which is archived here)
17.5.2. Solving the equations
There is no known analytic solution for these equations, but following the example from Differential Equations we can implement a simple program in Python or in C to solve these equations using Euler’s method.
Go ahead and download the program lotka_volterra.py
and
run it, saving the output into a file, and then plotting it:
$ chmod +x ./lotka_volterra.py
$ ./lotka_volterra.py > l-v.out
$ gnuplot
# at the gnuplot> prompt you can type:
set grid
plot 'l-v.out' using 1:2 with lines title 'prey'
replot 'l-v.out' using 1:3 with lines title 'predator'
17.6. Further reading
https://www.youtube.com/watch?v=NYq2078_xqc - Khan Academy video with pleasant intro to cycles and real examples, 5min.
https://www.youtube.com/watch?v=mFDiiSqGB7M - crash course on predator-prey ecology
https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations#A_simple_example
http://mc-stan.org/users/documentation/case-studies/lotka-volterra-predator-prey.html
Still have to look at articles on 3-way predator-prey:
chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/https://www.cs.unm.edu/~forrest/classes/cs365/lectures/Lotka-Volterra.pdf
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.360.1552&rep=rep1&type=pdf
And how about simple models of a full society collapse?
https://en.wikipedia.org/wiki/Collapse:_How_Societies_Choose_to_Fail_or_Succeed
http://necsi.edu/projects/evolution/co-evolution/pred-prey/co-evolution_predator.html
https://www.ted.com/talks/jared_diamond_on_why_societies_collapse
https://faustusnotes.wordpress.com/2014/05/15/mathematical-modeling-of-civilization-collapse/
Cliometrics