Math 1180 - Mathematics for Life Scientists Due April 9, 2007

advertisement
Math 1180 - Mathematics for Life Scientists
Lab 7 - Exponential and Poisson Distributions
Due April 9, 2007
Getting Started
As usual, make a new directory for this lab. Then warm up Maple for today's problems with the
commands:
>
>
>
>
>
with(stats):
iread(binomial);
iread(histplot);
iread(Poisson);
iread(iter);
Poisson Package
The Poisson package contains three commands. The rst, typed as
> Poi(k,Lambda);
gives the value of the Poisson probability distribution denoted p(k; ), the probability of exactly k
events with parameter . The second, typed as
> Poicum(k1,k2,Lambda);
gives the cumulative probability of between k1 and k2 events (inclusive). The last, typed
> Poiplot(Lambda,N);
plots out the Poisson probability distribution with parameter up to a maximum of N (because the
theoretical maximum is innite).
Problems
1. Suppose events occur at rate = 0:3. Input this in the usual way:
> lambda:=0.3;
Maple has a command to generate values from an exponentially distributed random variable T
with the command
> u:=x -> random[gamma[1,1/lambda]](1);
The gamma distribution is a generalized version of the exponential distribution, and the rst 1
tells Maple to use the exponential. Notice that the second parameter is 1=. The function u
can be thought of as an updating function that receives the iteration (or event) number, x, as an
input and outputs the wait time, T , for that iteration.
Pick a seed value for your random variable (so that you don't get the same answer as everyone
else from the random number generator) and set seed equal to this value. For example, if you
were to choose 1001, you would type
> _seed:=1001;
(Choose a dierent number.) Use iterplot to draw from the exponential distribution 20 times.
> iterplot(u,20,0);
Recall that the third input of iterplot is just an initial value. It can be thought as the value of
the random variable T at the 0th drawing; we just set it to 0 here.
Using your knowledge of the exponential distribution from class, nd the mean and the standard
deviation. Use this to nd the coecient of variation. Recall that the coecient of variation is a
measure of uncertainty, so a value near 0 means the random variable is likely to be close to the
mean and a value near 1 means the random variable is likely to have a large range and be far
from the mean. Using this information, explain your graph. What are the axes? Why do you
expect or not expect a pattern, and is this conrmed with the graph?
2. The exponentially distributed random variable T describes the waiting time between events. If
the n-th event occurs at time t, the next (n + 1)-th event occurs at time t + T . The updating
function describing this process is
> g := t -> t+u();
Reset
seed
to your chosen value. Use the same value as you used previously in problem 1.
> _seed:=1001;
Now, run process above using iterplot for 20 steps.
> iterplot(g,20,0);
What does your y-axis represent? How many events occurred by time t = 20? Using the plot
from problem 2, mark the two longest waits and their durations. Does this match the two longest
waits and their durations from the plot in problem 1?
3. The number of events at time 20 should be described by a Poisson distribution with parameter
= 20. Input this into Maple as follows:
> Lambda:=20*lambda;
Use the Poiplot command to plot this distribution up to a reasonable upper bound N , say 16.
> Poiplot(Lambda,16);
Let the number of events that occurred by time 20 in problem 2 be k. Using the commands for
the probability distribution and cumulative distribution given in the beginning of the exercise,
compute the probability of exactly k, fewer than or equal to k, and more than k events. Indicate the areas associated with each of these events on your graph. Do you consider your result
(concerning the number of events that occured by time 20) from problem 2 peculiar?
Download