CHAPTER 4

1

1a

Set up the Leslie matrix:

L=Table[0,{7},{7}];

L[[1]]={.32,.57,.57,.57,.57,.57,.57};
L[[2,1]]=.46;L[[3,2]]=.77;L[[4,3]]=.65;
L[[5,4]]=.67;L[[6,5]]=.64;L[[7,6]]=.88;

TableForm[L]

Iterate for 50 generations:

n[0]={10,10,10,10,10,10,10};
Do[n[t]=L.n[t-1],{t,50}]

Find the total population size, and its ratio in successive generations:

Do[tot[t]=Apply[Plus,n[t]],{t,0,50}]

Table[tot[t]/tot[t-1],{t,50}]

Find the age distribution in successive generations:

age=Table[100.0 n[t]/tot[t],{t,0,50}];

TableForm[N[age,4]]

1b

Find the eigenvalues and eigenvectors and display the eigenvalues and their absolute values:

{vals,vecs}=Eigensystem[L];

vals

Abs[vals]

Find the stable age distribution from the eigenvector corresponding to the dominant eigenvalue:

newage=100 vecs[[1]]/Apply[Plus,vecs[[1]]]

1c

The left eigenvectors of a matrix are the right eigenvectors of its transpose.

{lvals,lvecs}=Eigensystem[Transpose[L]];

lvals

repvalue=lvecs[[1]]/lvecs[[1,1]]

2

2a

Set up the l[[x]] and m[[x]] vectors and define the function of lambda, f[λ] = Σλ–x l[[x]] m[[x]]:

temp={.25,.46,.77,.65,.67,.64,.88};
l=Table[Product[temp[[i]],{i,x}],{x,7}];

m={1.28,2.28,2.28,2.28,2.28,2.28,2.28};

f[lambda_]:=Sum[lambda^(-x)*l[[x]]*m[[x]],{x,7}]

Plot this function of λ to establish the root approximately, and then use FindRoot to find it exactly given its approximate value:

Plot[f[lambda],{lambda,.9,1.1}]

FindRoot[f[lambda]==1,{lambda,1}]

2b

c=Table[1.0385^(-x)*l[[x]],{x,7}];

c=100 c/Apply[Plus,c]

3

Calculate the mean age and estimate the annual mortality q and survival p. Hence find the expected numbers at different ages from the geometric distribution.

freq={92,37,22,12,6,3};

mean=Range[6].freq/172  //N

q=1/mean

p=1-q;

expected=Table[172*q*p^(i-1),{i,6}];

expected[[6]]+=172-Apply[Plus,expected];

The last step adds the expected numbers for ages 7+ to those of age 6. Now print out the the expected distribution to compare with the observed distribution, and calculate the chi-square criterion of goodness of fit.

expected

chisquare=Apply[Plus,(freq-expected)^2/expected]

4

See Exercise 1

5

Sum[x*1.0385^(-x)*l[[x]]*m[[x]],{x,7}]

6

6a

Define f[λ] and then solve f[λ] = 1; it may be assumed that the root is approximately 1, though you could plot the function to confirm this before using FindRoot.

f[lambda_]:=.01733 lambda^(-3)/(1-.942 lambda^(-1))

FindRoot[f[lambda]==1,{lambda,1}]

Changing the age of first breeding from 3 to 4 years:

f[lambda_]:=.01733*.942 lambda^(-4)/(1-.942 lambda^(-1))

FindRoot[f[lambda]==1,{lambda,1}]

6b

Define the function g in Equation 31 and then write the vector of parameters as a replacement list:

Clear[l,m,p]

g=l*m*lambda^(-3)/(1-p/lambda);

params={lambda->.9608,l->.0722,m->.24,p->.942};

Find the sensitivity of λ to changes in m from Equation 29. Note that the differentiation would not have worked if the parameters had been assigned values.

-D[g,m]/D[g,lambda]/.params

Find the sensitivity of λ to changes in l and p in the same way.