update on how to read data
This commit is contained in:
@@ -168,6 +168,280 @@ plt.show()
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== Binning of data =====
|
||||
Use the Hudson bay model to load data and make plot in R and with python
|
||||
|
||||
|
||||
|
||||
|
||||
!split
|
||||
===== Adding model complexity: Predator-Prey model from ecology =====
|
||||
|
||||
!bblock
|
||||
The population dynamics of a simple predator-prey system is a
|
||||
classical example shown in many biology textbooks when ecological
|
||||
systems are discussed. The system contains all elements of the
|
||||
scientific method:
|
||||
|
||||
* The set up of a specific hypothesis combined with
|
||||
* the experimental methods needed (one can study existing data or perform experiments)
|
||||
* analyzing and interpreting the data and performing further experiments if needed
|
||||
* trying to extract general behaviors and extract eventual laws or patterns
|
||||
* develop mathematical relations for the uncovered regularities/laws and test these by per forming new experiments
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== Case study from Hudson bay =====
|
||||
|
||||
!bblock
|
||||
Lots of data about populations of hares and lynx collected from furs in Hudson Bay, Canada, are available. It is known that the populations oscillate. Why?
|
||||
We shall demonstrate the scientific method by
|
||||
|
||||
o plotting the data
|
||||
o derive a simple model for the population dynamics
|
||||
o (fitting parameters in the model to the data)
|
||||
o using the model predict the evolution other predator-pray systems
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Hudson bay data =====
|
||||
|
||||
|
||||
!bblock
|
||||
% if FORMAT == 'ipynb':
|
||||
Most mammalian predators rely on a variety of prey, which complicates mathematical modeling; however, a few predators have become highly specialized and seek almost exclusively a single prey species. An example of this simplified predator-prey interaction is seen in Canadian northern forests, where the populations of the lynx and the snowshoe hare are intertwined in a life and death struggle.
|
||||
|
||||
One reason that this particular system has been so extensively studied is that the Hudson Bay company kept careful records of all furs from the early 1800s into the 1900s. The records for the furs collected by the Hudson Bay company showed distinct oscillations (approximately 12 year periods), suggesting that these species caused almost periodic fluctuations of each other's populations. The table here shows data from 1900 to 1920.
|
||||
% endif
|
||||
|
||||
|------------------------------------------------------|
|
||||
| Year | Hares (x1000) | Lynx (x1000)|
|
||||
|---------l-----------------------r--------------r------|
|
||||
| 1900 | 30.0 | 4.0 |
|
||||
| 1901 | 47.2 | 6.1 |
|
||||
| 1902 | 70.2 | 9.8 |
|
||||
| 1903 | 77.4 | 35.2 |
|
||||
| 1904 | 36.3 | 59.4 |
|
||||
| 1905 | 20.6 | 41.7 |
|
||||
| 1906 | 18.1 | 19.0 |
|
||||
| 1907 | 21.4 | 13.0 |
|
||||
| 1908 | 22.0 | 8.3 |
|
||||
| 1909 | 25.4 | 9.1 |
|
||||
| 1910 | 27.1 | 7.4 |
|
||||
| 1911 | 40.3 | 8.0 |
|
||||
| 1912 | 57 | 12.3 |
|
||||
| 1913 | 76.6 | 19.5 |
|
||||
| 1914 | 52.3 | 45.7 |
|
||||
| 1915 | 19.5 | 51.1 |
|
||||
| 1916 | 11.2 | 29.7 |
|
||||
| 1917 | 7.6 | 15.8 |
|
||||
| 1918 | 14.6 | 9.7 |
|
||||
| 1919 | 16.2 | 10.1 |
|
||||
| 1920 | 24.7 | 8.6 |
|
||||
|------------------------------------------------------|
|
||||
|
||||
!eblock
|
||||
|
||||
|
||||
|
||||
!split
|
||||
===== Plotting the data =====
|
||||
|
||||
!bblock
|
||||
@@@CODE src/plot_Hudson.py
|
||||
!eblock
|
||||
|
||||
% if FORMAT != 'ipynb':
|
||||
!split
|
||||
===== Hares and lynx in Hudson bay from 1900 to 1920 =====
|
||||
|
||||
FIGURE: [fig/Hudson_Bay_data, width=700 frac=0.9]
|
||||
% endif
|
||||
|
||||
|
||||
!split
|
||||
===== Why now create a computer model for the hare and lynx populations? =====
|
||||
!bblock
|
||||
% if FORMAT == 'ipynb':
|
||||
We see from the plot that there are indeed fluctuations.
|
||||
We would like to create a mathematical model that explains these
|
||||
population fluctuations. Ecologists have predicted that in a simple
|
||||
predator-prey system that a rise in prey population is followed (with
|
||||
a lag) by a rise in the predator population. When the predator
|
||||
population is sufficiently high, then the prey population begins
|
||||
dropping. After the prey population falls, then the predator
|
||||
population falls, which allows the prey population to recover and
|
||||
complete one cycle of this interaction. Thus, we see that
|
||||
qualitatively oscillations occur. Can a mathematical model predict
|
||||
this? What causes cycles to slow or speed up? What affects the
|
||||
amplitude of the oscillation or do you expect to see the oscillations
|
||||
damp to a stable equilibrium? The models tend to ignore factors like
|
||||
climate and other complicating factors. How significant are these?
|
||||
% else:
|
||||
* We see oscillations in the data
|
||||
* What causes cycles to slow or speed up?
|
||||
* What affects the amplitude of the oscillation or do you expect to see the oscillations damp to a stable equilibrium?
|
||||
* With a model we can better *understand the data*
|
||||
* More important: we can understand the ecology dynamics of
|
||||
predator-pray populations
|
||||
% endif
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== The traditional (top-down) approach =====
|
||||
|
||||
!bblock
|
||||
The classical way (in all books) is to present the Lotka-Volterra equations:
|
||||
|
||||
!bt
|
||||
\begin{align*}
|
||||
\frac{dH}{dt} &= H(a - b L)\\
|
||||
\frac{dL}{dt} &= - L(d - c H)
|
||||
\end{align*}
|
||||
!et
|
||||
|
||||
Here,
|
||||
|
||||
* $H$ is the number of preys
|
||||
* $L$ the number of predators
|
||||
* $a$, $b$, $d$, $c$ are parameters
|
||||
|
||||
Most books quickly establish the model and then use considerable space on
|
||||
discussing the qualitative properties of this *nonlinear system of
|
||||
ODEs* (which cannot be solved)
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== The ``new'' discrete bottom-up approach =====
|
||||
|
||||
!bblock The bottom-up approach
|
||||
!bpop
|
||||
* Start with experimental data and discuss the methods which have been used to collect the data, the assumptions, the electronic devices, the aims etc. That is, expose the students to the theory and assumptions behind the data that have been collected and motivate for the scientific method.
|
||||
* Where appropriate the students should do the experiment(s) needed to collect the data.
|
||||
* The first programming tasks are to read and visualize the data to see if there are patterns or regularities. This strengthens a research-driven intuition.
|
||||
* Now we want to increase the understanding through modeling.
|
||||
* Most of the biology lies in the *derivation* of the model. We shall
|
||||
focus on an intuitive discrete approach that leads to difference
|
||||
equations that can be programmed *and solved* directly.
|
||||
!epop
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Basic (computer-friendly) mathematics notation =====
|
||||
!bblock
|
||||
* Time points: $t_0,t_1,\ldots,t_m$
|
||||
* Uniform distribution of time points: $t_n=n\Delta t$
|
||||
* $H^n$: population of hares at time $t_n$
|
||||
* $L^n$: population of lynx at time $t_n$
|
||||
* We want to model the changes in populations, $\Delta H=H^{n+1}-H^n$
|
||||
and $\Delta L=L^{n+1}-L^n$ during a general time interval $[t_{n+1},t_n]$
|
||||
of length $\Delta t=t_{n+1}-t_n$
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Basic dynamics of the population of hares =====
|
||||
|
||||
!bblock
|
||||
The population of hares evolves due to births and deaths exactly as a bacteria population:
|
||||
|
||||
!bt
|
||||
\[
|
||||
\Delta H = a \Delta t H^n
|
||||
\]
|
||||
!et
|
||||
However, hares have an additional loss in the population because
|
||||
they are eaten by lynx.
|
||||
All the hares and lynx can form
|
||||
$H\cdot L$ pairs in total. When such pairs meet during a time
|
||||
interval $\Delta t$, there is some
|
||||
small probablity that the lynx will eat the hare.
|
||||
So in fraction $b\Delta t HL$, the lynx eat hares. This
|
||||
loss of hares and must be accounted for:
|
||||
subtracted in the equation for hares:
|
||||
|
||||
!bt
|
||||
\[ \Delta H = a\Delta t H^n - b \Delta t H^nL^n\]
|
||||
!et
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Basic dynamics of the population of lynx =====
|
||||
|
||||
!bblock
|
||||
We assume that the primary growth for the lynx population depends on sufficient food for raising lynx kittens, which implies an adequate source of nutrients from predation on hares. Thus, the growth of the lynx population does not only depend of how many lynx there are, but on how many hares they can eat.
|
||||
In a time interval $\Delta t HL$ hares and lynx can meet, and in a
|
||||
fraction $b\Delta t HL$ the lynx eats the hare. All of this does not
|
||||
contribute to the growth of lynx, again just a fraction of
|
||||
$b\Delta t HL$ that we write as
|
||||
$d\Delta t HL$. In addition, lynx die just as in the population
|
||||
dynamics with one isolated animal population, leading to a loss
|
||||
$-c\Delta t L$.
|
||||
!eblock
|
||||
|
||||
!bblock
|
||||
The accounting of lynx then looks like
|
||||
!bt
|
||||
\[ \Delta L = d\Delta t H^nL^n - c\Delta t L^n\]
|
||||
!et
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Evolution equations =====
|
||||
|
||||
!bblock
|
||||
By writing up the definition of $\Delta H$ and $\Delta L$, and putting
|
||||
all assumed known terms $H^n$ and $L^n$ on the right-hand side, we have
|
||||
|
||||
!bt
|
||||
\[ H^{n+1} = H^n + a\Delta t H^n - b\Delta t H^n L^n \]
|
||||
!et
|
||||
|
||||
!bt
|
||||
\[ L^{n+1} = L^n + d\Delta t H^nL^n - c\Delta t L^n \]
|
||||
!et
|
||||
|
||||
Note:
|
||||
|
||||
* These equations are ready to be implemented!
|
||||
* But to start, we need $H^0$ and $L^0$ <linebreak>
|
||||
(which we can get from the data)
|
||||
* We also need values for $a$, $b$, $d$, $c$
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== Adapt the model to the Hudson Bay case =====
|
||||
|
||||
!bblock
|
||||
* As always, models tend to be general - as here, applicable
|
||||
to ``all'' predator-pray systems
|
||||
* The critical issue is whether the *interaction* between hares and lynx
|
||||
is sufficiently well modeled by $\hbox{const}HL$
|
||||
* The parameters $a$, $b$, $d$, and $c$ must be
|
||||
estimated from data
|
||||
* Measure time in years
|
||||
* $t_0=1900$, $t_m=1920$
|
||||
!eblock
|
||||
|
||||
!split
|
||||
===== The program =====
|
||||
|
||||
!bblock
|
||||
@@@CODE src/Hudson_Bay.py
|
||||
!eblock
|
||||
|
||||
% if FORMAT != 'ipynb':
|
||||
!split
|
||||
===== The plot =====
|
||||
|
||||
FIGURE: [fig/Hudson_Bay_sim, width=700 frac=0.9]
|
||||
|
||||
% else:
|
||||
If we perform a least-square fitting, we can find optimal values for the parameters $a$, $b$, $d$, $c$. The optimal parameters are $a=0.4807$, $b=0.02482$, $d=0.9272$ and $c=0.02756$. These parameters result in a slightly modified initial conditions, namely $H(0) = 34.91$ and $L(0)=3.857$. With these parameters we are now ready to solve the equations and plot these data together with the experimental values.
|
||||
% endif
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user