Random Variate Generation - University of Pittsburgh

[Pages:47]Random Variate Generation

CS1538: Introduction to Simulations

Random Variate Generation

Once we have obtained / created and verified a quality random number generator for U[0,1), we can use that to obtain random values in other distributions

Ex: Exponential, Normal, etc.

There are several techniques for generating random variates

Some are more efficient than others Some are easier to implement than others

2

Methods for Generating Random Variates

Method 1: Inverse Transform Method 2:Accept/Reject Method 3: Special Properties

Method #1: Inverse Transform Technique

Applicable to distributions with a closed mathematical formula

There is some function F-1 that maps values from U[0,1) into the desired distribution

4

Inverse Transform

Suppose we want to sample from some continuous distribution with CDF F(x) = Pr(X x).

We want to know the inverse of F(x), F-1(x).

That is, F(F-1(x)) = F-1(F(x)) = x

Example: x2 and sqrt(x) are inverses of each other

Because we know that 0 F(x) 1, the outcome of F(x) can be represented by a draw from U[0,1), call that R.

If we know F-1(x), we can get a sample from the desired distribution by calculating F-1(R).

Inverse Transform

General strategy for finding F-1(x):

Begin with: y = F(x) Go through some algebra to write the equation in terms of

x = G(y) G(y) is basically the F-1(x) we're looking for.

Example: Exponential Distribution

CDF for Exponential Distribution:

F

(

x)

0 , 1

x elx ,

0

x

0

We want to find F-1(x) such that F-1(F(x)) = x

F-1(x) = (-1/l) ln(1-x)

7

Example: Exponential Distribution

CDF for Exponential Distribution:

F

(

x)

0 , 1

x elx ,

0

x

0

We want to find F-1(x) such that F-1(F(x)) = x

F-1(x) = (-1/l) ln(1-x)

Implement in code:

def rand_expon(lambda): R = rand() return -ln(1-R)/lambda

9

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download