Professional Documents
Culture Documents
ICS 2307
Modelling and Simulation
Random Variates
There are several techniques for generating random
variates
These include:
Inverse Method
Convolution Method
Acceptance-rejection method
The inverse method is particularly suited for analytically
tractable probability density functions,
The remaining methods deal with more complex cases
such as the normal
2
F ( x) 2tdt
F ( x) [t ]
2 x
0
F ( x) x
x r
4
f ( x)
1
,a x b
ba
0, otherwise
1
F ( x)
dt
ba
a
t x
F ( x) [
]a
ba
xa
F ( x)
ba
7
xa
r F ( x)
ba
x r (b a ) a
f ( x) e
,0 x
f (t ) e
,t 0
F (t ) e x dx
0
F (t ) [e x ]t0
9
F (t ) 1 e
r F (t ) 1 e t
r 1 e t
1 r e t
ln(1 r ) ln(e t )
ln(1 r ) t
ln(1 r )
t
log(r )
10
Convolution Method
3) Sampling from an Erlang distribution
The m-Erlang random variable is the statistical sum
(convolutions) of m independent and identically
distributed exponential random variables
If y represents the m-Erlang random variable, ten
y=y1+y2++ym
where yi, i=1,2,,m are independent and identically
distributed exponential random variables whose
probability density function is defined as
11
Convolution Method
f ( yi ) e yi
yi>0, i=1,2,,m
y
y
12
Convolution Method
4) The Normal Distribution
A random variable x with pdf
Convolution Method
A random variable x follows a normal distribution with
mean and standard deviation then the random
variable z
z
14
Convolution Method
The central limit theorem states that
if x1, x2, xn are n independent random variates
with parameters mean and std then, and we
n
have y defined
as
y xi
1
15
Convolution Method
The procedure for generating random variables from the
normal distribution will this require generation of n values
of the uniform distribution
The random variables associated with these values have
mean=1/2 and variance =1/12
Therefore when the variable got from a summation of n of
these variables will have a normal distribution with
=n/2 and 2=n/12
i.e y has the normal distribution given below
n
n
f ( y) N ( ,
)
2 12
16
Convolution Method
y can be mapped into the standard normal distribution to
produce a new variable z using
z
Thus z is given by
z
yn/2
n / 12
n
12
(( y n / 2) )
x
u
n / 12
17
Convolution Method
If we take n=12, this simplifies to
x ( y 6) u
In summary, this means that
1) We generate y by generating and summing 12 random
variables (r1r12), y=r1++r12
2) We subtract 6 from y,
3) Multiply the difference in two with the standard deviation
for the distribution we want to sample
4) Add the mean to the product of 3 to get our random
variate x
18
Convolution Method
This method is slow because of the need to generate 12
random values
A more efficient procedure calls for using the
transformation
z1 ( 2 ln(r1 ) ) cos(2r2 ), and
z 2 ( 2 ln(r1 ) ) sin( 2r2 ),
Convolution Method
5) Poisson Distribution
If the distribution of the time between the occurrence of
successive events is exponential, then the distribution of
the number of events per unit time is Poisson
This relationships is used to sample the Poisson
distribution
If the Poisson distribution has a mean value of events
per unit time,
The time between events is exponential with mean=1/
time units
This means that a Poisson sample,n, will occur during t
time units iff
20
Convolution Method
The time between events is exponential with mean=1/
time units
This means that a Poisson sample,n, will occur during t
time units iff
Period until event n occurs t<period until event
n+1 occurs
this is translated to
t1+t2++tn t < t1+t2++tn+1 , n>0
0 t<t1 , n=0
This means that we sample the exponential samples do
we need so that the condition that the left side of the
inequality is less than or equal
to t and the right side
21
Convolution Method
The following discussion shows how this is implemented
Using the explanation for the m-Erlang random variable,
We can get a sample consisting of n identically distributed
exponential random variables using the formula
1
1
ln(r1 r2 ... rn ) t ln(r1 r2 ... rn 1 ), n 0
0t
ln(r1 ), n 0
Which reduces to
r1 r2 rne-t> r1 r2 rn+1, n>0
1 e-t>r1, n=0
22
Convolution Method
In summary, this means that
is the number of events per unit time,
And we want a sample of how many events will occur in a
time t
First we obtain the value of e-t
Case 1
If we generate the first random value r1 and it is less than
e-t, then we have a sample of 0, I.e. our Poisson random
variable n takes the value 0.
Note that if e-t is greater than 1, we will never get a
sample of 0 coz the relevant inequality will never be
satisfied
23
Convolution Method
Case 2
i.
24
We set k to 0
27
g ( x)
, x
g ( y)dy
g ( x1 )
2) If
, accept x1as a sample from f(x) else
reject x1 and repeat from 1
28
r Pi 1
x xi 1 ( xi xi 1 )
Pi Pi 1
Where r is greater than Pi-1 but less or equal to Pi
33