Homework 3 Solution

1. Discrete population model (Ex. 1, p.159)

(a) Define initial population distribution

p0=Table[(100-n)(25+n),{n,0,99}];
TableForm[ArrayReshape[Table[{i-1,p0[[i]]},{i,1,Length[p0]}],{20,10}],TableHeadings->{{},Flatten[Table[{"Age","Pop"},10]]}]

(b) The total initial population

Total[p0]

(c) Define the birth rate vector

f=Table[If[n≥21&&n≤30,1.9/2./10.,0.],{n,0,99,1}];
TableForm[ArrayReshape[Table[{i-1,f[[i]]},{i,1,Length[f]}],{20,10}],TableHeadings->{{},Flatten[Table[{"Age","rBirth"},10]]}]

(d) Define the death, survival rate vectors

mu=Table[Min[1,0.0524 (Exp[0.03n]-1)],{n,1,99,1}];
s=1-mu;
TableForm[ArrayReshape[Table[{i-1,s[[i]]},{i,1,Length[s]}],{20,10}],TableHeadings->{{},Flatten[Table[{"Age","rSurv"},10]]}]

(e) Define the Leslie matrix

S:=DiagonalMatrix[s];
L:=Prepend[Map[Append[#,0]&,S],f];
L[[1;;25,21;;25]]//MatrixForm

(f) Compute the total population in the next 20 years

p={p0};
For[i=1,i≤20,i++,AppendTo[p,L.p[[-1]]]];
TableForm[Table[{i,Round[Total[p[[i]]]]},{i,1,Length[p]}]]

Leslie matrix eigenstructure

L1={{1,2/3},{1/2,0}};MatrixForm[L1]

L2={{0,4,3},{1/2,0,0},{0,1/4,0}};MatrixForm[L2]

N[Eigensystem[L1]] // MatrixForm

N[Eigensystem[L2]] // MatrixForm

Population evolution

Histogram[pY]

μY=30; μM=45; μO=65; σ=5; nPop=100000;
pY=Table[RandomVariate[NormalDistribution[μY,σ]],nPop];
pM=Table[RandomVariate[NormalDistribution[μM,σ]],nPop];
pO=Table[RandomVariate[NormalDistribution[μO,σ]],nPop];
pB = Select[Table[RandomVariate[NormalDistribution[0,8σ]],8nPop], #>0 &];
pYB=Flatten[{pY,pB}];
pMB=Flatten[{pM,pB}];
pOB=Flatten[{pO,pB}];
GraphicsGrid[{{Histogram[pYB]},{Histogram[pMB]},{Histogram[pOB]}}]

dYB=HistogramList[pYB]

dMB=HistogramList[pMB]

dOB=HistogramList[pOB]

rB=rD=0.02; nBin=Length[dYB[[1]]]-1;
f=Table[rB,nBin]; s=Table[1-rD,nBin-1];
S:=DiagonalMatrix[s];
L:=Prepend[Map[Append[#,0]&,S],f];

pYB = dYB[[2]];
For[i=1,i≤3,i++, pYB = L.pYB];
BarChart[pYB]