160 likes | 521 Views
Simulation Modeling and Analysis. Sampling from Probability Distributions. 1. Outline. Inverse Transforms for Random Variate Generation Direct Transform and Convolution Acceptance-Rejection Technique. 2. Inverse Transforms for Random Variate Generation.
E N D
Simulation Modeling and Analysis Sampling from Probability Distributions 1
Outline • Inverse Transforms for Random Variate Generation • Direct Transform and Convolution • Acceptance-Rejection Technique 2
Inverse Transforms for Random Variate Generation • Random variates are required to simulate the vagaries of arrivals, service, processing and the like which take place in the real world. • Once a reliable RNG is available, how does one use it to obtain random variates with selected statistical distributions? 3
Steps in Inverse Transform Method 1.- Determine the cdf for the desired RV X. 2.- Set F(X) = R 3.- Solve F(X) = R for X in terms of R. I.e. X = F-1(R) 4.- Generate the necessary RN sequence Ri and use it to compute corresponding values Xi for i = 1,2,…, n 4
Inverse Transform Method for the Exponential Distribution 1.- F(x) = 1 - e - x , x > 0 2.- F(X) = 1 - e - x = R 3.- X = - (1/) ln (1 - R) 4.- For i = 1,2,…, n Xi = - (1/) ln (1 - Ri) • Example: Use RAND in Excel to create 1000 PRN’s and transform them to E. Examine your results in Stat::Fit. 5
Inverse Transform Method for the Uniform Distribution 1.- F(x) = {(x-a)/(b-a) ; 0 for a < x < b 2.- F(X) = (X -a)/(b-a) = R 3.- X = a + (b-a) R 4.- For i = 1,2,…, n Xi = a + (b-a) Ri • Example: Use RAND in Excel to create 1000 PRN’s and transform them to U. Examine your results in Stat::Fit. 6
Inverse Transform Method for the Weibull Distribution 1.- F(x) = 1 - e -x/) , x > 0 2.- F(X) = 1 - e -X/) = R 3.- X = [ ln (1 - R)]1/ 4.- For i = 1,2,…, n Xi = [ ln (1 - Ri )]1/ • Example: Use RAND in Excel to create 1000 PRN’s and transform them to W. Examine your results in Stat::Fit. 7
Inverse Transform Method for the Triangular Distribution 1.- F(x) = {0, for x <0; x2/2 for 0<x<1; 1-(2-x)2/2, for 1 <x<2; 1, for x > 2. 2.- R=X2/2 (0<X<1) and R = 1- (2-X)2/2 (1<X<2) 3.- X = 2R1/2 , (0<R<1/2); X = 2 - (2(1-R))1/2 , (1/2<R<1) • Example: Use RAND in Excel to create 1000 PRN’s and transform them to W. Examine your results in Stat::Fit. 8
Inverse Transform Method for Empirical Distributions • Similar procedure applies • 1.- Determine the empirical cdf F(x) • 2.- Generate R • 3.- Using the F(X) curve determine the corresponding value of X. 9
Transform Method for Distributions without Closed Form Inverse • Normal, gamma and beta distributions have no closed form inverses. Inverse transform method is applicable only approximately. • For example, for the standard normal distribution X ~ (R0.135 - (1-R) 0.135)/0.1975 • Example: Use RAND in Excel to create 1000 PRN’s and transform them to N. Examine your results in Stat::Fit. 10
Inverse Transform Method for Discrete Distributions • Similar method applies. • Lookup table • Algebraic 11
Direct Transform for the Normal • For the normal distribution F(x) = -x (1/(2)1/2) e -(t2/2) dt • Box-Muller method (pp. 341-343) Z1 = (-2 ln R1)1/2 cos(2 R2) Z2 = (-2 ln R1)1/2 sin(2 R2) X1 = + Z1 X2 = + Z2 12
Convolution Method • Convolution: the probability distribution of two or more independent RV • Useful for Erlang and binomial variates • Erlang w/parameters (K, • Sum of K independent exponential RV each with mean 1/K X = -(1/ K ) ln Ri 13
Acceptance-Rejection Technique • Say random variates X are needed uniformly distributed between 1/4 and 1 • Steps 1.- Generate R 2a.- If R > 1/4 make X = R and go to 3 2b.- If R < 1/4 go to 1 until X is obtained 3.- Repeat from 1 for another X 14
Acceptance-Rejection Technique for Poisson Distribution • Recall Poisson and exponential are closely related. P(N=n) = e n/n! • Steps 1.- Set n =0, P=1 2.- Generate R and replace P by P R 3.- If P < e , accept N = n, otherwise go to 2 15
Acceptance-Rejection Technique for Gamma Distribution • Steps 1.- Compute a = (2-1)1/2 ; b = 2 - ln 4 + 1/a 2.- Generate R1, R2 3.- Compute X = [R1/(1-R1)]a 4a.- If X > b-ln(R12R2) reject and go to 2 4b.- If X < b-ln(R12R2) use X as is or as X/ 16