Stochastic Process Worksheet by sry33301

VIEWS: 29 PAGES: 22

More Info
									Created by Claudia Neuhauser
Worksheet 1: Stochastic Processes


An Introductory Example

Van Bael, S. and S. Pruett-Jones. 1996. Exponential population growth on Monk
Parakeets in the United States. Wilson Bulletin 108(3):584-588.

Abstract:




Van Bael and Pruett-Jones used records from the National Audubon Society Christmas
Bird Count (CBC) during the winters from 1971-72 to 1994-95. The CBC is a citizen
science effort where thousands of citizens count birds in designated 15-mile diameter
sample areas (http://www.audubon.org/bird/cbc/index.html). This event has taken place
Worksheet 1: Stochastic Processes


for over one hundred years during the winter holiday season (December 14 to January 5),
and has resulted in a large amount of data.


IN-CLASS ACTIVITY

The following data set from the CBC was used in Van Bael and Pruett-Jones (1996) as a
proxy for population size. We will use this data set to build a model that describes the
population growth of this species.


                                   NumberOfMonkParakeets
                            Year     PerPartyHour(effort)
                             76             0.030
                             77             0.031
                             78             0.035
                             79             0.027
                             80             0.041
                             81             0.048
                             82             0.026
                             83             0.048
                             84             0.064
                             85             0.083
                             86             0.177
                             87             0.121
                             88             0.234
                             89             0.200
                             90             0.393
                             91             0.414
                             92             0.436
                             93             0.387
                             94             0.387
                             95             0.501

(a) Graph the data in EXCEL. Set year 1976 equal to 76 on your graph. Describe the
    growth. (Tab “Parakeet Data”)
(b) The accompanying paper mentions “exponential population growth” in its title. How
    can you decide whether an exponential function is a suitable description? (We will
    talk more about this in the second module.)
(c) What assumptions are made to infer population size from the CBC data?




                                          -2-
Worksheet 1: Stochastic Processes


Exponential Growth

Deterministic Models

Many species reproduce in distinct seasons. Populations of such species are then best
modeled using discrete time models. In their simplest form where the population size at
generation t+1, denoted by Nt+1, only depends on the population size at time t, denoted by
Nt, we can model this recursively as

                N t 1  f ( N t ), t  0,1,2,

As the initial condition, we need to specify the population size at time 0, N0. If the
population size from one generation to the next is multiplied by a constant factor,
exponential growth results. The recursive equation for this type of growth is

(1)                     N t 1  RN t , t  0,1,2,

where R is a nonnegative constant, called the growth parameter. We assume that R  0 .
To use this recursion, we need to specify the population size at time 0, N0. This model
can be solved explicitly, that is, we can find a function g(t) that describes the population
size explicitly as a function of t. Here is how to find the function:

                        N1  RN0
                        N 2  RN1  RRN0   R 2 N 0
                                                  
                        N 3  RN 2  R R 2 N 0  R 3 N 0
                        
                        Nt  Rt N0

Thus,

(2)                     Nt  Rt N 0

is the solution of (1). It is an exponential function. Figure 1 shows the behavior of the
graph of this function.




                                                  -3-
Worksheet 1: Stochastic Processes


                                    Exponential Growth and Decay

                     500
   Population Size

                     400
                     300                                                     R=0.9
                     200                                                     R=1.1
                     100
                       0
                           0           5            10             15   20
                                                Generation



Figure 1: Exponential growth (R=1.1) and decay (R=0.9)

Note that for 0  R  1 , the population size is decreasing exponentially (exponential
decay), whereas for R  1 , it is increasing exponentially (exponential growth). We can
express the long-term behavior formally using limits. Namely,

                                          0 if 0  R  1
                                          
                                lim N t   N 0 if R  1
                               t 
                                            if R  1
                                          

In this model, the population size is viewed as a continuous variable. This is an
approximation since a population size is measured in number of individuals, which is a
discrete variable. In the model, if the initial population size is positive, the population
size will remain positive for all times. As a consequence, if a population is declining in
size, the population size will approach zero but never be equal to zero, and population
sizes that are unrealistic, namely positive but less than one, will result. Modeling a
population size with a continuous variable has the advantage that analytical tools are
better developed for continuous variables than for discrete variables. Having tools for
rigorous analysis allows us to go beyond simulations, which makes the results more
robust.


A Very Brief Introduction to EXCEL and MATLAB


IN-CLASS ACTIVITY

EXCEL

We will use an EXCEL spreadsheet (Tab: “Logistic Growth”) to code exponential
growth for R  0.5,1,2 and determine the population size for t=1,2,…,20 when the



                                                             -4-
Worksheet 1: Stochastic Processes


population size is 1 at time 0. Let‟s take the recursive equation [Equation (1)] and the
explicit function [Equation (2)] and set up a spreadsheet in the following way.

       A           B            C           D
 1            Discrete Time Logistic Growth
 2
 3     Parameters
 4     R            N_0
 5            0.5              1
 6
 7     Time         Equation (1)    Equation (2)
 8              0               1              1
 9              1             0.5            0.5
 10             2            0.25           0.25
 11             3          0.125          0.125
 12             4         0.0625         0.0625



 In Row 5, enter the parameters.
 In Cell A8, enter 0; in Cell A9, enter 1. Highlight both Cells A8 and A9 and drag them
  down to time 20.
 In Cell B8, enter “=$B$5”, in Cell B9, enter “=$A$5*B8”. Explain why.
 In Cell C8, enter “=$B$5*$A$5^A8”. Explain why.
 Drag Cell B9 down to time 20; drag C8 down to time 20. Note that the two equations
  yield the same answers (which you should expect).
 You can now change the parameter R in cell A5 and explore the behavior.

Office 2003: Graphical explorations are very valuable and we will graph Nt as a function
of t using Equations (1). To graph this, highlight the array you want to include in the
graph (i.e., cells A7-A28 and B7-B28), and click on the Chart Wizard on your
spreadsheet (follow instructions during lecture). Choose XY (Scatter) from the options
and click on Next. The Wizard will guide you through the steps to label the graph. It is
important to choose the appropriate chart type. Since this is a discrete time model, you
need to plot the values at the discrete times 0,1,2,…, which you can do by choosing the
appropriate Chart sub-type. Sometimes it is useful to connect the dots but you should
make sure that the markers remain visible.

Office 2007: Graphical explorations are very valuable and we will graph Nt as a function
of t using Equations (1). To graph this, highlight the array you want to include in the
graph (i.e., cells A7-A28 and B7-B28), and click on the Insert tab. Choose Scatter in
the Charts group, and click on the Scatter with only Markers option. This will plot
population size as a function of time. It is important to choose the appropriate chart type.
Since this is a discrete time model, you need to plot the values at the discrete times
0,1,2,…, which you can do by choosing the appropriate Chart sub-type. Sometimes it is
useful to connect the dots but you should make sure that the markers remain visible.
Label the graph.



                                                   -5-
Worksheet 1: Stochastic Processes



MATLAB

MATLAB is a much more sophisticated software program than EXCEL. We will use
both of these programs. EXCEL is very easy to use and gives you immediate feedback. It
is excellent for exploring models. However, if you work on a research project, MATLAB
is typically more appropriate (unless the model is really simple).

In MATLAB, you write your programs in m-files. We‟ll use exponential growth to
explain how you get a program running, including creating a plot. Write the following
into an m-file. Save the m-file as “expgrowth.”

%exponential growth
clear
r=1.5; %parameter for growth
endtime=21; %end time
popsize=zeros(1,endtime); %initializing the population row vector
popsize(1)=20; %initializing the population size at time 0

generation=0:1:endtime-1; %specifying the generation vector
for i=1:endtime-1
    popsize(i+1)=r*popsize(i); %recursive form
end

plot(generation, popsize,'kx')
xlabel('Generation')
ylabel('Population Size')
title(['Exponential Growth with parameter R=', num2str(r)])

To run this in MATLAB, you need to go to the Command Window and type the file
name, i.e., expgrowth. This will generate a graph. Make sure that MATLAB looks for the
file in the appropriate directory. You might need to change the directory. The command
for changing directories is cd(‘directory name’)


Stochastic Models

Stochastic or random processes are ubiquitous in biology. Yet, stochasticity is rarely
included in models of population or community dynamics. The theory of stochastic
processes is quite well developed but is in general not as straightforward as the analysis
of deterministic processes. Simulations can help a great deal to get a better sense of the
effects of stochasticity. Let‟s again look at the simplest population growth model,
exponential growth in discrete time:

                                        N t 1  RN t

The parameter R, which is assumed to be positive, is the growth parameter. We
investigated the behavior of this model and found that the solution is



                                            -6-
Worksheet 1: Stochastic Processes


                                               Nt  N0 Rt

We can define a critical value where the behavior changes, namely Rc  1 . For 0  R  1 ,
the population goes extinct, whereas for R  1 , the population will grow indefinitely
provided N0  0 . We assumed in this model that the parameter R is the same in each
generation. This, of course, need not be. There are many factors that may change the
parameter R from time step to time step. In Figure 2, we compare deterministic
exponential growth and stochastic exponential growth. In this figure, we set R=1.05 in
the deterministic case and let R vary randomly between 0.85 and 1.25 (i.e., 1.05  0.2 ) in
the stochastic case (we will give a precise definition below of “vary randomly”). Figure 2
shows a single realization of this stochastic process and compares it to a deterministic
process with the same value of R.


                                Exponential Growth

   140
   120
   100
    80                                                                stochastic
    60                                                                deterministic
    40
    20
     0
         0       20        40        60        80         100   120
                                Generation



Figure 2: Stochastic and deterministic exponential growth.

The simulation of the exponential growth was done in EXCEL. EXCEL has a random
number generator that generates pseudo-random variables that are uniformly distributed
in the interval (0,1). The function is RAND() and when entered this way into a cell will
generate a pseudo-random number. Since this is a function you need to type „=RAND()‟
into the cell (without the quotation marks). Try it! Use the F9 key to get a different
realization. To get an idea of how a population behaves in a random environment, we
need to repeat this simulation many times. This is better done in MATLAB.

Before we can code up exponential growth in a random environment in either EXCEL or
MATLAB, we need to develop the theory further. We will begin our discussion with
defining the uniform distribution and then explain how a computer can generate random
numbers that follow this distribution. We will then introduce a number of other
distributions and explain how to simulate these.




                                                    -7-
Worksheet 1: Stochastic Processes


The Uniform Distribution

A random variable X is uniformly distributed over the interval (a,b) if the probability that
the random variable falls into a subinterval of a given length that is contained in (a,b) is
proportional to the length of the subinterval.


  a                      c                   d                                               b

Figure 3: The uniform distribution over the interval (a,b).

                                                                d c
                                          P( X  (c, d )) 
                                                                ba

Another way to describe this distribution is to use the distribution function. A
distribution function of a random variable X is defined as F ( x)  P( X  x) . A
distribution function is a nondecreasing function between 0 and 1. It has the property

                                   lim F ( x)  1 and lim F ( x)  0
                                   x                       x 


If X is uniformly distributed over the interval (0,1), then the distribution function is given
by

            0 for x  0                                      1
           
  F ( x)   x for 0  x  1
           1      for x  1
           

                                                                                                 x
                                                                       0            1
                                              Figure 4: The distribution function of a uniform distribution.

The distribution function of this random variable is a continuous function (Figure 4). We
therefore call the random variable a continuous random variable. We can use the
distribution function to compute probabilities, such as P(c  X  d ) . Namely,

                                     P(c  X  d )  F (d )  F (c)

The uniform distribution can also be described by a density function. A density function
 f ( x) is defined as

                                                       x
                                            F ( x)    
                                                       
                                                            f (u )du



                                                    -8-
Worksheet 1: Stochastic Processes


and has the properties

                                          f ( x)  0
                                          

                                          
                                         
                                              f ( x)dx  1



                                                                    d
It follows from the fundamental theorem of calculus that f ( x)      F ( x) where F ( x) is
                                                                   dx
differentiable. Therefore, the density function of a uniformly distributed random variable
over the interval (0,1) is given by

                                           0 for x  0 or x  1
                                  f ( x)  
                                           1      for 0  x  1




Task 1

The density function of a uniformly distributed random variable over the interval
(a,b), a  b , is given by

                                   0 for x  a or x  b
                                  
                         f ( x)   1
                                   b  a for a  x  b
                                  

                                                                    d c
Find the distribution function and verify that P( X  (c, d ))          , provided
                                                                    ba
a c  d b.


Below, we will need the expectation of a random variable. The expected value of a
random variable X that is distributed according to a probability distribution with density
 f ( x) is given by

                                        EX   xf ( x)dx

if the integral is defined.




                                               -9-
Worksheet 1: Stochastic Processes


Example: Find the expected value of a uniformly distributed random variable over the
interval (a, b) with a  b .

Solution: Using the definition EX   xf ( x)dx and the result of Task 1, we need to
evaluate

                                               b 2  a 2 (b  a)(b  a) b  a
                                               b
                                 1 1 2 
                   b
                      1
            EX   x      dx           x                             
                  a
                    ba        b  a  2  a 2(b  a)
                                                            2(b  a )        2
We find that the expected value of X is the midpoint of the interval (a, b) .


To define the expected value of a function of a random variable, let X be a random
variable that is distributed according to a probability distribution with density f ( x) and
let g ( x) be a function. Then

                                    Eg ( X )   g ( x) f ( x)dx

if the integral is defined.

Task 2

Let X be a uniformly distributed random variable on the interval (a,b), 0  a  b ,
with density function

                                   0 for x  a or x  b
                                  
                         f ( x)   1
                                   b  a for a  x  b
                                  

(a) Find ln EX for general values of a and b. (b) Find E  ln X  for general values of
a and b. (c) Compare your results in (a) and (b) for a=1 and b=2.


Random Number Generator

Generating pseudo-random numbers on a computer is surprisingly simple. Here is an
algorithm that generates pseudo-random variables that are uniformly distributed over
(0,1). We define three numbers, a, c, and m, and a positive number, called seed, I 0  m .
The following algorithm defines a sequence of numbers that generates both a new seed
and the pseudo-random number:

(3)                                  I j 1  (aI j  c ) mod m


                                              - 10 -
Worksheet 1: Stochastic Processes



Here is an example with a  106, c  1283, m  6075 and I 0  4567 :

                   aI 0  c (106)(4567)  1283        5460
                                               79        79.898765...
                      m            6075               6075

The new seed is I1  5460 and the pseudo-random variable is u  0.898765... .

The numbers that are generated this way are not truly random. In fact, with m  6075 ,
there are at most 6075 different seeds this algorithm can produce, namely all the integers
between 0 and 6074. Once the algorithm produces an integer that has already come up,
the pseudo-random numbers will repeat the previous numbers. The shorter the cycle
length, the worse the algorithm. In fact, the algorithm we gave above is a really bad
random number generator since its cycle length is quite short, less than m  6075 .
        There are tables that list combinations of numbers for a, c, and m that produce
better sequences of pseudo-random numbers. There are also more sophisticated
algorithms. Researchers have developed criteria to check whether a random number
generator is “good.”

IN-CLASS ACTIVITY

Set up a spreadsheet (Tabb: “Random Number Generator”) to generate 10 pseudo-
random variables using the algorithm provided in Equation (3) with
a  106, c  1283, m  6075 and I 0  4567 .

         A           B              C                 D                E
  1
  2            a               c               m              I_0
  3                      106            1283          6075                 4567
  4
  5            j               aI_j+c          seed           random number
  6                                                   4567
  7                       0        485385             5460          0.898765432
  8                       1
  9                       2
 10                       3
 11                       4
 12                       5
 13                       6
 14                       7
 15                       8
 16                       9
 17                      10

Cell C7: =($B$3*D6+$C$3)
Cell D7: =MOD(C7,$D$3)


                                                          - 11 -
Worksheet 1: Stochastic Processes


Cell E7: =D7/$D$3

EXCEL can produce pseudo-random numbers as well. The random number generator in
EXCEL can be called using the command RAND(). It is known to be a bad random
number generator since it has a short cycle length. Even though the random number
generator in EXCEL should never be used for scientific research, it is good enough for
educational purposes to illustrate effects of stochasticity, provided not too many pseudo-
random variables are called. If you enter “=RAND()” into a cell in an EXCEL
spreadsheet and hit Enter, you will see a number between 0 and 1 appearing in the cell.
Every time you hit the F9 key, EXCEL will generate a new pseudo-random number. Try
it!


Generating Other Random Variables

Discussion1: Suppose you wanted to generate pseudo-random variables that come from a
generator that generates uniform random variables over the interval (0,1). How would
you proceed?

We wish to generalize this approach to arbitrary continuous distributions. The following
result will help us (Figure 5).

Theorem. If X is distributed according to a distribution given by the distribution function
F ( x) , then F ( X ) is uniformly distributed over the interval (0,1).

Proof. The proof is very short: For 0  u  1 ,

                     P  F ( X )  u   P( X  F 1 (u))  F (F 1 (u))  u .

How do we use this theorem? We generate a random variable that is uniformly
distributed over (0,1). Call this random variable U. We next compute the inverse function
of F ( x) , denoted by F 1 ( x ) . The random variable we seek is then X  F 1 (U ) .


                       F(x)



                       U


                                                                 x
                                     X
Figure 5: Finding random variables with arbitrary, continuous distribution functions.


1
    You would generate a uniform random variable in (0,1) and then multiply the outcome by 2.


                                                    - 12 -
Worksheet 1: Stochastic Processes



Example: Suppose a random number generator that generates uniformly distributed
pseudo-random numbers in the interval between (0,1) generated the following two
pseudo-random variables: 0.3858 and 0.8627. Use these two pseudo-random variables to
generate uniformly distributed pseudo-random variables in the interval (0,2).

Solution: Informally, we already know that we need to multiply each of the
pseudorandom variables by 2 since we “stretch” the interval (0,1) by 2 to get a uniform
distribution on (0,2). But let‟s see how we would proceed more formally. The distribution
                                                                                x
function of a uniform random variable in the interval (0,2) is given by F ( x)  for
                                                                                2
0  x  2 . To invert the distribution function, we compute

                                               x
                                           y
                                               2
                                           x  2y

which means that F 1 ( x)  2 x (after interchanging the roles of x and y). Hence, we find

                       Y1  F 1 (0.3858)  (2)(0.3858)  0.7716
                       Y2  F 1 (0.8627)  (2)(0.8627)  1.7254


The Bernoulli Distribution

The Bernoulli distribution is a discrete distribution. We say that a random variable X is
Bernoulli distributed with parameter p if X takes on two values, 0 and 1, with
probabilities p and 1-p, respectively. That is,

                       P( X  1)  p  1  P( X  0)

We can use a random number generator to generate Bernoulli distributed random
variables as follows. Let U denote the random variable that is uniform on (0,1) and by X
the Bernoulli random variable with parameter p. Generate a uniform random variable and
assume that the outcome is u. If u is between 0 and p, then assign the value 1 to X,
otherwise, assign the value 0.

IN-CLASS ACTIVITY

We will use the random number generator RAND() in EXCEL to generate Bernoulli
pseudo-random variables with parameter p  0.3 . Suppose the parameter p is stored in
the cell C3, then the command “=IF(RAND()<$C$3,1,0)” will produce a Bernoulli
random variable with that parameter p. Set up a spreadsheet (Tab: “Bernoulli”) to
produce 10 Bernoulli pseudo-random variables.


                                           - 13 -
Worksheet 1: Stochastic Processes


The Binomial Distribution

The binomial distribution is a discrete distribution. We say that a random variable X is
binomially distributed with parameters p and n if X takes on value k, where k takes on
values 0,1,2,…,n, with probability
                                             n
                                P( X  k )    p k 1  p 
                                                              n k

                                             k 

A binomial distribution models the number of successes in n trials where each trial is a
Bernoulli experiment with success probability p.

Exponential Growth in a Temporally Varying Environment

We now return to exponential growth in a temporally varying environment. We define
the population size at generation t as N t , and set

(4)                                        Nt 1  Rt Nt

We assume now that the growth parameter Rt may vary from generation to generation.
Iterating Equation (4), we find

(5)                               Nt   Rt 1Rt 2 ...R1R0  N0

If we set

                               Rt   Rt 1Rt 2 ...R1R0 
                               ˆ                          1/ t




                                         ˆ                         ˆ
we can write Equation (5) as Nt  Rtt N0 . The new parameter Rt is called the geometric
mean of the numbers R0 , R1 ,..., Rt 1 . Whether or not the population will grow thus
depends on the geometric mean of the growth parameters that define the growth in each
generation.


Geometric and Arithmetic Averages

You might be more familiar with arithmetic averages. If you have a series of positive
numbers, x1 , x2 ,..., xn , then the arithmetic average is given by

                                         1
                                   x       x1  x2  ...  xn 
                                         n

The geometric average of the same set of numbers is given by



                                               - 14 -
Worksheet 1: Stochastic Processes


                                            x   x1 x2 ...xn 
                                                                1/ n
                                            ˆ

Below, we will show that x  x , that is, the geometric average is at most as large as the
                           ˆ
arithmetic average. But first an example that illustrates this:

Example: Find the arithmetic and the geometric average of the ten integers, 1,2,…,10.

Solution: We find

                                      1
                                x      1  2  ...  10   5.5
                                     10
                                x   (1)(2)(3)...(10) 
                                                         1/10
                                ˆ                                4.52787...

illustrating that the geometric average is less than the arithmetic average.

To show that arithmetic averages exceed geometric averages, we need the following
inequality (which is a special case of Jensen‟s inequality),

                              x  x  ...  xn    ln x1  ln x2  ...  ln xn
(6)                       ln  1 2                
                                    n                         n

provided x1 , x2 ,..., xn  0 . This follows from the fact that f ( x)  ln x is concave down.



                                                                         y=f(x)
      f[(x1+x2)/2]


 [f(x1)+f(x2)]/2




                          x1           (x1+x2)/2                   x2

Figure 6: Jensen‟s inequality when n=2.



If we exponentiate both sides of Inequality (6) and then simplify, we find

         1 n          1 n               1      n
                                                               n         n
                                                                          1/ n
                                                                                        
                                                                                         1/ n

            xk  exp  n  ln xk   exp  n ln  xk   exp ln   xk      xk 
                       k 1      
                                                                                    
         n k 1                                 k 1         
                                                                   k 1       
                                                                                  k 1




                                                   - 15 -
Worksheet 1: Stochastic Processes


Back to Exponential Growth

The fact that the geometric average is at most as large as the arithmetic average has
important implications for population growth. When a population is followed for several
generations to determine the long-term behavior, it is important to compute the geometric
average as this is the average that determines whether the population will grow or
decline. Computing the arithmetic average overestimates the long-term growth parameter
(and is meaningless). To gain a better understanding of how to determine long-term
behavior, note that

                         ˆ   R R ...R 1/ t  exp  1  ln R 
                                                        t 1
(7)                      Rt     t 1 t  2 0                 j 
                                                     t j 0    

The long-term growth is determined by the arithmetic average of the logarithms of the
growth parameters R j . Note that

                                            t 1
                                    ˆ 1
                                 ln Rt   ln R j
                                        t j 0


If you have had a course in statistics, you have likely heard about the Law of Large
Numbers. The Law of Large Numbers can be used to say more about this stochastic
model. Namely, it says that if ln R j has finite expectations, then

                                           t 1
                                          1
(8)                      lim ln Rt  lim  ln R j  E  ln R0 
                                ˆ
                         t         t  t
                                            j 0



This allows us to predict the behavior of the stochastic model, similar to the deterministic
model.

IN-CLASS ACTIVITY

         Generate 200 iid U(0,1) random variables
                                                                            X1  X 2     Xn
         Computer the arithmetic averages for n  1, 2,          , 200 :
                                                                                     n
         Plot the arithmetic averages as a function of n


A Random Walk View of Growth in Temporally Varying Environments

We described population growth in a temporally varying environment by Equation (5)

                                 Nt   Rt 1Rt 2 ...R1R0  N0


                                                   - 16 -
Worksheet 1: Stochastic Processes



If we take natural logarithms on both sides and use ln(ab)  ln a  ln b repeatedly, we
find

                                                      t 1
                                   ln N t  ln N 0   ln Ri
                                                      i 0



In this formulation, ln Nt is a random walk. That is, it is a sum of independent and
identically distributed random variables. The theory of random walk is very well
developed and we can quote results to understand the behavior.

The result that is most relevant to us is that if the expected value of the increments is
greater than 0, the random walk will go off to  with probability 1; if the expected
value of the increments is less than 0, the random walk will go off to  with probability
1. If we apply this to our population growth model, we find that with probability 1,

                                             if E ln R0  0
                                lim ln Nt  
                                t 
                                             if E ln R0  0

Translating this into results for the population size N t , we find that with probability 1,

                                          if E ln R0  0
                                lim Nt  
                                t 
                                          0 if E ln R0  0

It is important to remember that E ln R0  ln ER0 . This is Jensen‟s Inequality and implies
that the arithmetic average of the growth parameters could be positive and the population
could still go extinct since the average of the logarithm of the growth parameters counts.

Note that we did not say anything about the behavior of this model when E ln R0  0 . In
this case, the process is called a one dimensional, symmetric random walk. Figure 7
shows a one-dimensional, symmetric random walk where at each time step, with
probability 0.5 the random walker goes up one unit or down one unit. We highlighted a
few paths. This is a case where the mean displacement is 0.

The figure was generated using the following MATLAB script:

%Random Walk RW.m
clear
%size=input('Time:');
size=1000;
time=0:1:size-1; %specifying the generation vector
rep=100;
A=-3+2*unidrnd(2,rep,size);
B=cumsum(A,2);



                                             - 17 -
Worksheet 1: Stochastic Processes

plot(time, B,'-k.','MarkerSize',1)


                                                    Random Walk
          100


           80



           60


           40


           20



            0



          -20


          -40


          -60



          -80
                0   100      200     300      400       500       600   700    800     900     1000
                                                       Time




Figure 7: One hundred realizations of a symmetric random walk starting at the origin as a function of time




                                                    - 18 -
Worksheet 1: Stochastic Processes


Homework (HAND IN ON __________________________)

Make sure you save your work frequently. Each step will give explicit instructions on
what to hand in. Most of the time, you will need to copy a table or graph together with
relevant EXCEL spreadsheet cells into a WORD file.

   Hand in Tasks 1 (page 9) and 2 (page 10)

Step 1

Simulate Nt 1  Rt Nt for t  0,1, 2,...,100 , when Rt is uniformly distributed over the
interval ( R  a, R  a) . Compute both the arithmetic and the geometric averages of the
growth parameters. (Use Equation (7) to compute the geometric mean.) Note that EXCEL
has a function that computes averages: If numbers are stored in cells A1 to A6, for
instance, then the average of these numbers can be computed using
“=AVERAGE(A1:A6)” Set up the spreadsheet as follows:


                           A          B              C         D           E
                    1
                    2
                    3
                    4                 R              a         N_0
                    5                     1.05           0.5         1
                    6
                    7
                    8               Time         stochastic    R_t       ln R_t
                    9                       0        1 1.363059 0.309732
                   10                       1 1.363059 0.816726 -0.20245
                   11                       2 1.113246 1.280248 0.247053
                   12                       3 1.425231 1.522973 0.420664
                   13                       4
                   14                       5
                   15                       6
                   16                       7
                   17                       8



Row 5 has the parameters R and a, and the initial population size N 0  1 .

C9: =D5
D9: =C10/C9
E9: =LN(D9)
C10: =C9*(2*$C$5*RAND()+$B$5-$C$5)
D10: =C11/C10
E10: =LN(D10)



                                             - 19 -
Worksheet 1: Stochastic Processes


To explain cell C10, note that we first need to find the distribution function of the
uniform distribution on the interval ( R  a, R  a) , then invert the distribution function
and use the Theorem on page 10. Assume now that X is uniformly distributed on
                                                                         1
( R  a, R  a) . The density function of this distribution is f ( x)     for
                                                                        2a
R  a  x  R  a , and equal to 0 otherwise. Hence the distribution function is

                                               0 for x  R  a
                                    x 1
                                   
                          F ( x)            du for R  a  x  R  a
                                      R  a 2a
                                   
                                   
                                               1 for x  R  a

                                    1
For R  a  x  R  a , F ( x)        x  R  a  . Hence,
                                   2a

                                             1
                                         y     x  R  a
                                            2a
                                        2ay  x  R  a
                                        x  2ay  R  a

We thus see that if Y is uniformly distributed on (0,1), then X  2aY  R  a is uniformly
distributed on ( R  a, R  a) . This is what we entered in cell C10.

(a) Set R  1.05 , a  0.2 , and N 0  1 . Compare the result to deterministic exponential
growth with parameter R  1.05 . Produce a graph like the one in Figure 2 and copy the
graph into a WORD file. If you hit the F9 key on your keyboard, you can look at different
realizations.

(b) Change the parameters to R  1.2 and N 0  1 , and vary a between 0 and 0.5. Explain
in words what you see.

(c) Change the parameters to R  1.05 and N 0  1 , and vary a between 0 and 0.5. Explain
in words what you see. Compare your results in (b) and (c).


Step 2

To model discrete population sizes, you can, for instance, round down numbers to the
nearest integer. EXCEL provides such a function: INT( ): If you enter into a cell
“=INT(20.9),” EXCEL will respond with “20.” To begin your explorations, repeat Step 1
for a discrete population size. Explore one aspect of this model further, for instance, you
could vary the initial population size for different growth parameters or vary the amount
of stochasticity by changing the parameter a. What are the main differences? Are there


                                               - 20 -
Worksheet 1: Stochastic Processes


cases where the discrete population size and the continuous population size models are
similar? When are they different? Include relevant graphs into your WORD file to
explain your observations.


Homework (HAND IN ON ___________________)


Step 3

(a) Use an EXCEL spreadsheet to simulate population growth in a randomly varying
environment according to
                           Nt   Rt 1Rt 2 ...R1R0  N0
where the growth parameters Ri are independent and identically distributed according to
a uniform distribution on (a, b) with a  b . Explain how you coded this up. (b) Choose
values for a and b such that the population size grows without bounds and another set of
values of a and b such that the population goes extinct. Provide graphs for each case
                                                                               t 1
                                                                        ˆ 1
where you plot the population size as a function of time. (c) Recall ln Rt   ln R j . Plot
                                                                             t j 0
   ˆ
ln R as a function of t for a=1.0 and b=2.0. In light of Equation (8), what do you expect
    t

                                                           ˆ
the graph to look like for large values of t? (d) Find E ln Rt for a=1.0 and b=2.0 and
compare your answer with what you found in (c).


Step 4

Assume that a population grows in a randomly varying environment according to
                             Nt   Rt 1Rt 2 ...R1R0  N0
where the growth parameters Ri are independent and identically distributed according to
a uniform distribution on (a, b) with a  b . Set a  R  v and b  R  v . (a) Find ER0 .
(b) Find E ln R0 . (c) Set v  0.2 . Determine the critical value of R, denoted by Rcr , so
that if R  Rcr , the population grows without bounds, whereas if R  Rcr , the population
goes extinct. (Hint: Find an equation for Rcr . You will not be able to algebraically solve
the equation. Resort to some numerical way of finding a value for Rcr .) (d) Use the
EXCEL spreadsheet you developed in Step 3 to explore how easy it would have been to
find the critical value using simulations alone. Report your findings.


Step 5

Writing Assignment:
(1) Summarize the main points of this module in bullet points.


                                           - 21 -
Worksheet 1: Stochastic Processes


(2) “Focused freewriting” means you put your pen to paper for a fixed number of minutes
    and write nonstop for this period of time. Don‟t worry about sentence structure,
    grammar, spelling, or appearance. If you get stuck, keep writing about what comes to
    your mind, even if it is just “I am stuck, I am stuck,…” Use focused freewriting for
    five minutes to reflect on what you found most surprising or puzzling in this module.
(3) Use your focused freewriting exercise to come up with a question about this module.




                                         - 22 -

								
To top