CSCI2202 Lab C: Fibonacci Matrix, Markov Chains & Linear Predator-Prey###

$30.00

Download Details:

  • Name: LabC-hr8f8d.zip
  • Type: zip
  • Size: 116.72 KB

Category:

Description

5/5 - (1 vote)

Problem 1a. The Fibonacci recurrence is: \begin{align} f[n+1] &= f[n] + f[n-1] \qquad \qquad {for } \quad n > 2 \ [f_1, f_0]^T &= [1, 0]^T \ \end{align} Express this as a matrix-vector relation: Gxk=xk+1 where xk=[fk,fk−1]T & xk+1=[fk+1,fk]T

( Where G is a 2×2 matrix).

Find the matrix G for this transformation. Carry out the matrix multiplication for 8 steps. Use {\tt numpy.linalg.matrix_power} (See : Fibbonacci Numbers in nature).

The matrix is of interest. This matrix can be the starting point of carry out population distribution studies among animals in their various life-stages (more in Tuesday’s lecture)

Problem 1b Use the matrix power function from numpy.linalg.matrix_power and calculate G3,G5,G10. Do you notice anything about the elements of the matrices (you may also want to look at Assignment 1).

Problem 2 In the following problem, you are going to apply matrix-vector multiplication to study a (linear) Predator-Prey interaction.

In the forests of N. California, Dusky-footed Wood Rats provide 80% of the diet for the Northern Spotted Owl. First, try a simple linear model of the dynamical system that makes up the owls and the rats.

The populations at timestep 𝑘 are given by xk=[Owlsk,Ratsk], where Ratsk are in 1000′𝑠 of rats.

In the absence of predation (by owls), the rat pop grows by 10% per month (this is the timestep for the model). With no rats for food, the owl population falls to one-half the pop in the prev month. The predation rate of rats is p (take p = 0.104 to start the experiment).

Since we have a linear model, there are no Owl-Rat interactions (encounters) in the model, we simulate that by an “efficiency* by which the Owls turn Rats into Owls with a conversion efficiency of 0.4 (i.e. when there are abundant Rats, the Owl pop rises by 0.4∗𝑅𝑎𝑡𝑠.

\begin{align} Owls_{n+1} &= 0.5\cdot Owls_n + 0.4\cdot Rats_n\ Rats_{n+1} &= -p\cdot Owls_n + 1.1\cdot Rats_n\ \end{align}

Solve this as a matrix equation by generating 𝑥1,𝑥2,…𝑥𝑘 as usual. Remember, each xi=[Owlsi,Ratsi]. Use k=50. Store the Owl numbers, in each step i, in an array Owl[i] and the Rat numbers (in 1000’s) in another array Rats[i].

Using the arrays Owl[i]Rats[i], make (i) a plot of the Owl Pop. v/s Time and the Rat Pop. v/s Time on the same axes. Now, since this is a difference equation, the time step (of a month) is implicit in the model. The time axis is generated using the numpy function linspace with k intervals (make endpoint=True). {\bf On the same plot} (ii) Plot Owl[i] v/s Rat[i].

Experiment with [Owl0,Rats0]=[20,40], [35,40] [45,40] [60,40] [80,40] Experiment with changing the predation rate p (pick 4 different values to see the effects on the curves obtained).

To plot numpy arrays X,Y on the same time t axes: *plt.plot(t, X, ‘r-‘, t, Y, ‘b–‘)

To make 2 plots side-by-side; use the *matplotlib.pyplot function subplot(1,2,1) before the first plot command and subplot(1,2,2) before the second plot command)