Sale!

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

$30.00 $21.00

Original Work ?

Download Details:

  • Name: LabC-9cmvgy.zip
  • Type: zip
  • Size: 116.72 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Problem 1a. The Fibonacci recurrence is:

f[n+1][f1,f0]T=f[n]+f[n1]forn>2=[1,0]T�[�+1]=�[�]+�[�−1]����>2[�1,�0]�=[1,0]�

Express this as a matrix-vector relation: Gxk=xk+1���=��+1 where xk=[fk,fk1]T��=[��,��−1]� & xk+1=[fk+1,fk]T��+1=[��+1,��]�

( Where G is a 2×22×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�3,�5,�10. 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 k𝑘 are given by xk=[Owlsk,Ratsk]��=[�����,�����], where Ratsk����� are in 1000s1000′𝑠 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.4Rats0.4∗𝑅𝑎𝑡𝑠.

Owlsn+1Ratsn+1=0.5Owlsn+0.4Ratsn=pOwlsn+1.1Ratsn�����+1=0.5⋅�����+0.4⋅����������+1=−�⋅�����+1.1⋅�����

Solve this as a matrix equation by generating x1,x2,xk𝑥1,𝑥2,…𝑥𝑘 as usual. Remember, each xi=[Owlsi,Ratsi]��=[�����,�����]. Use k=50�=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][���0,����0]=[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)