THE POISSON PROCESS
101
Consequently, we want a to be as small as possible (that is, as close as possible to 1).
What
"small enough" means is context-dependent, but generally speaking,
if
a > 10,
the envelope is not
adequate-
too many points will be rejected, so a better envelope
needs to be found.
If
this is not practical, then an entirely new approach is required.
4.7
The Poisson process
Consider a Poisson process with rate>. defined on the interval
[0,
T].
As we know, the
inter-event times are
Exp(>.),
and so we have a very simple algorithm for simulating
realisations
of
the process. Initialise the process
at
time zero. Then simulate t
1
"'
Exp(>.),
the time to the first event, and put X
1
= t
1
.
Next simulate t
2
"'
Exp(>.),
the time from the first to the second event, and put X
2
= X
1
+ t
2
.
At step
k,
simulate
tk
""'Exp(>.),
thetimefromthe
k-1
to
kthevent,andputXk
= Xk_
1
+tk.
Repeat
until
Xk > T, and keep the X
1
,
X2,
...
as the realisation
of
the process.
4.8 Using the statistical programming language, R
4.8.1 Introduction
R is a programming language for data analysis and statistics.
It
is a completely free
open-source software application, and very widely used by professional statisticians.
It
is also very popular in certain application areas, including bioiuformatics. R is a
dynamically typed interpreted language, and it is typically used interactively.
It
has
many
b~Jilt-in
functions and libraries and is extensible, allowing users to define their
own functions and procedures using
R,
C,
or
Fortran. It also has a simple object
system. R is a particularly convenient environment to use for stochastic simulation,
visualisation, and analysis. It will therefore be used in the forthcoming chapters in
order to provide concrete illustrations
of
the theory being described.
It
is strongly rec-
ommended that readers unfamiliar with R download and install it, then work through
this mini-tutorial.
4.82
Vectors
Vectors are a fundamental concept in R, as many functions operate on and return
vectors, so it is best
to
master these as soon
as
possible. For the technically inclined,
in
R,
a (numeric) vector is an object consisting
of
a one-dimensional array
of
scalars.
>
rep(l,lO)
[1]
1 1 1 1 1 1 1 1 1 1
>
Here
rep
is a function that returns a vector (here, 1 repeated 10 times).
You
can get
documentation for
rep
by typing
>
?rep
You
can assign any object (including vectors) using the assignment
operator<-
(or
= ), and combine vectors and scalars with the c function.
j
'
•