Random Variate Generation-1
Random Variate Generation-1
RANDOM VARIATE
GENERATION
RANDOM VARIATE GENERATION
• BINOMIAL DISTRIBUTION
To generate binomially distributed random numbers,
one simulates the outcome of a trial of the experiment
by generating a standard uniform distribution random
number. After all n trials have been simulated (n
standard uniform numbers have been generated), the
value of the binomially distributed random variable is
simply a count of those standard uniform numbers that
are less than or equal to p. This procedure is useful for
small to moderate values of n. For large values of n, the
normal approximation to the binomial should be used.
RANDOM VARIATE GENERATION
• Example:
Generate a random number from a binomial
distribution with n = 7, p = 0.3.
To simulate seven trials, generate seven standard
uniform numbers.
Assume that the numbers are 0.02011, 0.85393,
0.97265, 0.61680, 0.16656, 0.42751, and 0.69994.
Now two of these numbers are less than p = 0.3, so
the desired binomial random number is X = 2.
RANDOM VARIATE GENERATION
•
RANDOM VARIATE GENERATION
• Suppose that we wish to generate a random number
from a Poisson distribution with λ = 2.5. Suppose
further that we have generated the standard uniform
random numbers 0.91646, 0.89198, 0.64809,
0.16376, 0.91782, 0.45624, 0.31642. Then e-2.5 =
0.08208, and
• (0.91646)(0.89198) = 0.81746 > 0.08208
• (0.91646)(0.89198)(0.64809) = 0.52979 > 0.08208
• (0.91646)(0.89198)(0.64809)(0.17376) = 0.08675 >
0.08208
• (0.91646)(0.89198)(0.64809)(0.17376)(0.91782)
=0.07963 < 0.08208
Then N = 5 and hence the value of the Poisson-
distributed random number is X = N – 1 = 4
RANDOM VARIATE GENERATION
1. EXPONENTIAL DISTRIBUTION
f(X) = α e-αx , where α = average number of occurrences per unit time (rate)
F(X) = ∫0x α e-αx dX = - e-αx ]0x = 1 - e-αx
Recall that F(R) = R, to get our exponential RV(X) from R, isolate X.
R = 1 - e-αx 1- R = e-αx
ln (1-R) = ln (e-αx ) = αX
X = { - ln( 1-R)} {1/ α }
RANDOM VARIATE GENERATION
(2,0) x
1
F(0 ≤ x ≤ 1) = ∫0 xdx = x2/2 ]10 = ½
F(0 ≤ x ≤ 1) = 1 – ½ = 1/2
RN f(x) x
0≤R≤½ x 0≤x≤1
1/2 ≤ R ≤ 1 2-x 1≤x≤2
Case 1: 0≤R≤½
x x
R = F(X) = ∫0 x dx = x2 /2 ]0 = x2 /2
Isolating X
R = x2 /2 2R
Case 2: 1/2 ≤ R ≤ 1
1 1
R = ∫X (2-x) dx + 1/2 = (2x-x2/2) ]X
= 2x - x2/2 – 2 + ½ + ½
= 2x-x2/2 - 1
Isolating X:
2R = 4x -x2 – 2 → x2 - 4x + 2 + 2R = 0
RANDOM VARIATE GENERATION
X = 4± 16 – 8 – 8R = 4± 8 – 8R = 4±2 2 – 2R
2 2 2
X = 2 ± 2 -2R since X ≤ 2 → 2 – 2-R
Summarizing
RN X X’
0≤R≤½ 2R √kR
1/2 ≤ R ≤ 1 2- 2-2R 1-√(1-k)(1-R)
Example k =(c-a)/(b-a) X= a + (b-a)X’
where a = 1, b = 4 and c = 3
R = 0.3879 → X = 2.5255
R = 0.7567 → X = 3.1456
Note: The formulas derived for the triangular are
dependent f(x), i.e., different f(x) will give different
X formulas
4. UNIFORM DISTRIBUTION
QUESTION: If the RN’s are from the uniform distribution, why
do we need an RVGen technique for the uniform
distribution?
f(x) f(x)
f(x)
a b