Section 8.3: Stochastic Models

Created by Tomas de-Camino-Beck
tomasd@math.ualberta.ca

Simple 1-Dimensional Random Walk

randomwalk = 
        NestList[(# + Random[Integer, {-1, 1}]) &, 0, 
          1000];

ListPlot[randomwalk, PlotJoined -> True]

If we simulate a 1000 steps of a large number of walkers, the final distribution of individuals in space will be a gaussian:

data = 
        Array[Nest[(# + Random[Integer, {-1, 1}]) &, 0, 
              1000] &, {1000}];

These two packages allow to calculate the frequency distribution and then generate a Bar chart

<< Statistics`DataManipulation`
<< Graphics`Graphics`

Compute frequencies:

freq = Frequencies[data]

Generate a bar chart:

BarChart[freq]

The mean of data should be approximately 0:

<< Statistics`DescriptiveStatistics`

Mean[data] // N

Demographic Stochasticity in matrix Models

<<Statistics`MultiDiscreteDistributions`
<<Statistics`DiscreteDistributions`
<<Graphics`MultipleListPlot`

From the same example as in Chapter 2, we now build demographic stochasticity.  This section uses an example from Caswell (2001).

T=(({{0, 0, 0, 0}, {0.9775, 0.9111, 0, 0}, {0, 0.0736, 0.9534, 0}, {0, 0, 0.0452, 0.9804}}));

F=(({{0, 0.0043, 0.1132, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}));

\(\(T_\&~ := Join[T, {1 - Total /@ Transpose[T]}];\)\)

Note that a multinomial distribution is used for the transitions matrix, and binomial for fecundities. The following code, just iterates so individuals move from stage to stage.

\(IterateSurvival[n_, T_] := 
      Drop[Total /@ \((Array[
                Random[MultinomialDistribution[n[\([#]\)], 
                      T\&~[\([All, #]\)]]] &, {Length[
                    n]}] \[Transpose])\), \(-1\)]\)

IterateFecundity[n_, F_] := 
      Total /@ Table[
          Random[BinomialDistribution[n[[j]], F[[i, j]]]], {i, 
            Length[n]}, {j, Length[n]}]

The following code does this for the the whole population:

IteratePopulation[n_, T_, F, t_] := 
      NestList[IterateSurvival[#, T] + IterateFecundity[#, F] &, n, 
        t]

Example

p = IteratePopulation[{1, 1, 1, 1}, T, F, 30];

mult = 
        Array[Total /@ 
              IteratePopulation[{1, 1, 1, 1}, T, F, 
                150] &, {20}];

MultipleListPlot[mult, PlotJoined -> True, 
      SymbolShape -> None]

References

Caswell H. 2001. Matrix population models : construction, analysis, and interpretation, 2nd edn. Sinauer Associates, Sunderland, Mass. .