RandomNumberGeneration

Download Report

Transcript RandomNumberGeneration

Random Number Generation
Dr. Jerrell T. Stracener,
Update: 1/31/02
SAE Fellow
1
Generating Random Numbers
Generating values of a random variable using the
probability integral transformation to generate a
random value y from a given probability density
function f(y):
1. Generate a random value rU from a uniform
distribution over (0, 1).
2. Set rU = F(y)
3. Solve the resulting expression for y.
2
Generating Random Numbers with Excel
From the Tools menu, look for Data Analysis.
3
Generating Random Numbers with Excel
If it is not there, you must install it.
4
Generating Random Numbers with Excel
Once you select Data Analysis, the following window will
appear. Scroll down to “Random Number Generation” and
select it, then press “OK”
5
Generating Random Numbers with Excel
We would like U(0, 1).
So select “Uniform” under the “Distribution” menu.
Type in “1” for number of variables and 10 for number of
random numbers. Then press OK. 10 random numbers of
uniform distribution will now appear on a new chart.
6
Generating Random Numbers
f(y)
y
F(y)
ri
1.0
0.8
0.6
0.4
0.2
0
1
2
3
y
yi
7
Generating Random Values from the Exponential
Distribution E()
• generate ri from U(0, 1)
• calculate
• since
xi = - ln(1 - ri)
ri  1  e

xi

for i = 1, 2, …, n
8
Generating an Exponential Distribution with Excel
See charts 7 - 10.
Select a  that you would like to use, we will use  = 5.
Type in the equation -ln(1 - ri), with filling in  as 5, and ri as cell A1. Now
with that cell selected, place the cursor over the bottom right hand corner of
the cell. A cross will appear, drag this cross down to B10. This will transfer
that equation to the cells below. Now we have an exponential distribution in
cells B1 - B10.
9
Generating Random Values from the Weibull
Distribution W(, )
• generate ri from U(0, 1)
• calculate
• since
xi = [-ln(1 - ri)]1/
ri  1  e
x 
 i 
 

for i = 1, 2, …, n
10
Generating a Weibull Distribution with Excel
See charts 7 - 10.
Select a  and  that you would like to use, we will use  = 100,  = 20.
Type in the equation xi = [-ln(1 - ri)]1/, with filling in  as 100,  as 20, and
ri as cell A1. Now transfer that equation to the cells below. Now we have an
Weibull distribution in cells B1 - B10.
11
Generating Random Values from the Lognormal
Distribution Ln(, )
• generate ri from N(0, 1)
• calculate
xi  e
• since
  ri
Ln xi =  + ri
for i = 1, 2, …, n
12
Generating a Lognormal Distribution with Excel
See charts 7 - 10.
Select a  and  that you would like to use, we will use  = 2,  = 1.
Type in the equation , xi  e   ri with filling in  as 2,  as 1, and ri as cell
A1. Now transfer that equation to the cells below. Now we have an
Lognormal distribution in cells B1 - B10.
13