18
Random-Variate Generation

04-Random-Variate Generation.ppt

Embed Size (px)

Citation preview

Page 1: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 1/18

Random-Variate Generation

Page 2: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 2/18

Page 3: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 3/18

Inverse Transform Technique --

Exponential Distribution

To generate samples from exponential distribution we use the inverse

transform technique

Step 1. Compute the cdf of the desired random variable X, F(x).

Step 2. Find the inverse of F(x) function

Step 4. Generate uniform random variables R 1, R 2, R 3, … and compute

the desired random variates by

0,0

0,)(

 x

 xe x  f  

 x  

0,0

0,1)(

 x

 xe x F 

 x 

)1ln(1

)(1)(   1  y y F  xe y x F  y   x  

 

 

)1ln(1

)(1 iii   R R F  X     

 

Page 4: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 4/18

Inverse Transform Technique --

Exponential Distribution

Page 5: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 5/18

Inverse Transform Technique --

Exponential Distribution

Example: Generate 200 variates Xi with distribution

exp(  = 1) 

Check: Does the random variable X 1 have the desired

distribution?

Page 6: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 6/18

Proof?

Can you prove that the numbers you have

generated are indeed samples from an

exponential distribution?

Page 7: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 7/18

Other Distributions

Uniform Distribution [ UN(a,b)] (X = a + (b-a)R) Does it really work?

Weibull Distribution

Derive the transformation

Triangular …. The moral is if we can find a closed-form inverse of thecdf for a distribution we can use this method to getsamples from that distribution

0,0

0,)(

1

 x

 xe x x  f  

 x    

   

   

  

Page 8: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 8/18

Continuous Functions without a

Closed-Form Inverse

Some distributions do not have a closed form expression

for their cdf or its inverse (normal, gamma, beta, …) 

What can be done then?

Approximate the inverse cdf

For the standard normal distribution:

This approximation gives at least one-decimal place

accuracy in the range [0.0012499, 0.9986501]

1975.0

)1()(

135.0135.01   R R R F  X 

   

Page 9: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 9/18

Discrete Distributions

An Empirical Discrete Distribution

 p(0) = P(X=0) = 0.50

 p(1) = P(X=1) = 0.30

 p(2) = P(X=2) = 0.20

Can we apply the inverse transform technique?

 x

 x

 x

 x

 x F 

2,0.1

21,8.0

10,5.0

0,0

)(

Page 10: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 10/18

Discrete Distributions

Let x0 = -, and x1, x2, …, xn, be the ordered probability

mass points for the random variable X

Let R be a random number

iii   x X  x F  R x F if       )()( 1

Page 11: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 11/18

Discrete Distributions

A Discrete Uniform Distribution

]1,1[

,1

,1,

1,0

)(

.,..,2,1,1

)(

 xk 

i  for i xik 

i

 x

 x F 

k  x

 x p

)(

1

kRroundup X or 

i X k 

i R

iif  

Page 12: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 12/18

Discrete Distributions

The Geometric Distribution

Some algebraic manipulation and … 

  ...,2,1,0,11)(

...,2,1,0,1)(

1

 x p x F 

 x p p x p

 x

 x

   

 

 

 

  1

1ln

1ln

 p

 Rroundup X 

Page 13: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 13/18

Acceptance-Rejection Technique

Useful particularly when inverse cdf does not exist inclosed form, a.k.a. thinning

Illustration: To generate random variates, X  ~ U(1/4, 1)

 R does not have the desired distribution, but R 

conditioned ( R’ ) on the event { R  ¼} does.

Efficiency: Depends heavily on the ability to minimizethe number of re ections.

Procedures:

Step 1. Generate R ~ U[0,1]

Step 2a. If R >= ¼, accept X=R.

Step 2b. If R < ¼, reject R, return

to Step 1

Generate R

Condition

Output R’ 

yes

no

Page 14: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 14/18

Acceptance-Rejection Technique

Poisson Distribution

 N can be interpreted as number of arrivals from a

Poisson arrival process during one unit of time

Then time between the arrivals in the process are

exponentially distributed with rate

 

...,2,1,0,

!

)()(  

n

n

en N  P n p

 

 

1

11

1n

i

i

n

i

i   A An N 

Page 15: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 15/18

Acceptance-Rejection Technique

Step 1. Set n = 0, and P = 1

Step 2. Generate a random number R n+1 and let P = P. R n+1 

Step 3. If P < e-, then accept N = n. Otherwise, reject

current n, increase n by one, and return to step 2

How many random numbers will be used on the average to

generate one Poisson variate?

1

11

1

11

1

11

ln1

1ln1

1

n

i i

n

i i

n

i

i

n

i

i

n

i

i

n

i

i

 Re R

 R R A A

 

  

Page 16: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 16/18

Direct Transformations

dxe x  t 

 x

2

2

2

1)(

 

 

Consider two normal variables Z1 and Z

2

2 2 2

1 2

1 1

2

1 1 2

2 1 2

~ with twodegrees of freedom

  (Exponential with parameter 2)

tan ~ [0, 2 ]

2 ln

2 ln cos 2

2ln sin 2

 B Z Z Chi square

 Z Uniform

 Z 

 B R

 Z R R

 Z R R

 

 

 

 

Page 17: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 17/18

Direct Transformation

Approach for  normal( m  ,s 2  ):

Generate Z i ~ N(0,1)

Approach for lognormal( m  ,s 2  ):

Generate X ~ N( m  ,s 2 

 )

Y i  = e X i  

 X i  = m  + s  Z 

i

Page 18: 04-Random-Variate Generation.ppt

8/14/2019 04-Random-Variate Generation.ppt

http://slidepdf.com/reader/full/04-random-variate-generationppt 18/18

Convolution Method

Erlang Distribution

An Erlang-K random variable X with parameters (K, ) (1/ is the

mean, K is the stage number) can be obtained by summing K

independent exponential random variables each having mean1/(K )

  

  

 K 

i

ii

 K 

i

 K 

i

i

 R K 

 R K 

 X 

 X  X 

11

1

ln1

ln1