IE306Lec7 - IE306 SYSTEMS SIMULATION Ali Rıza Kaylan [email protected] 1 LECTURE 7 OUTLINE Random Variate Generation Inverse Transformation

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: IE306 SYSTEMS SIMULATION Ali Rıza Kaylan [email protected] 1 LECTURE 7 OUTLINE Random Variate Generation Inverse Transformation Technique Composition Technique Convolution Technique Acceptance-Rejection Technique Poisson Variate Generation Normal Variate Generation 2 RANDOM VARIATE GENERATION RANDOM VARIATES X~F(x) {X1,X2,X3,...} RANDOM NUMBERS U~IIDUniform(0,1) {U1,U2,U3,...} f (u) = 1 0 0 F( u) = u 1 0≤ u≤1 Otherwise u<0 0 ≤u <1 1≤ u 3 RANDOM VARIATE GENERATION EXAMPLE: X ~ Uniform(2,6) X = 2 + (6 − 2)U f(u) f(u) 0.25 0 u 1 U=0.75 0 2 6 x X=5 4 RANDOM VARIATE GENERATION 0 x - 2 F( x ) = 4 1 x<2 2≤ x<6 6≤ x F(x) 1 0.75 0 x 2 6 X=5 5 INVERSE TRANSFORMATION TECHNIQUE 1. Generate a random number U~Uniform(0,1) −1 X = F (U ) 2. Set −1 P( X ≤ x ) = P( F (U ) ≤ x ) = P (U ≤ F( x )) = F ( x ) Example: X ~ Uniform(2,6) X-2 U= 4 X = 2 + 4U 6 INVERSE TRANSFORMATION TECHNIQUE Example: X ~ Exponential (β ) F( x ) = 1 − e ( − x / β ) , 0 ≤ x (− X/ β ) U = 1− e X = -β ln(1 − U ) 7 INVERSE TRANSFORMATION TECHNIQUE Example: X ~ Weibull ( β , α ) F ( x) = 1 − e − ( x / β )α ,0 ≤ x β is the scale and α is the shape parameter. U = 1− e − ( X / β )α X = β [− ln(1 − U )] 1/ α 8 COMPOSITION TECHNIQUE Mixtures of distributions: The population is composed of several subpopulations each with a different c.d.f. Then the population c.d.f. F(x) is expressed as a convex combination of the subpopulation c.d.f.'s. F (x) 1 F (x) 3 The pj's are known to be mixing proportions. 1. Generate a positive random integer J such that F (x) 2 ... F (x) k k F( x ) = ∑ p j F j ( x ) j =1 P( J = j ) = p j j = 1,2,..., k 2. Generate X from the subpopulation J. 9 COMPOSITION TECHNIQUE Example: 0.4 f ( x ) = 0.3 0 1≤ x ≤ 2 2≤x≤4 f (x) f (x) 1.0 1.0 2 1 Otherwise 0 f ( x ) = 0.4 f 1 (x ) + 0.6 f 2 (x ) f 1 (x ) = 1 1≤x≤2 f 2 (x ) = 0.5 2 ≤ x ≤ 4 1 2 3 x 4 0 1 2 3 x 4 f (x) 0.4 0 1 2 3 4 x 10 CONVOLUTION TECHNIQUE The random variable X is expressed as a sum of IID random variables X = Y1 + Y2 +... + Ym 1. Generate Y1, Y 2 ,..., Y m 2. Set X = Y1 + Y2 +... + Ym 11 ACCEPTANCE-REJECTION TECHNIQUE 0. Put an envelop over the density function. 1. Generate U1 , U2 2. Set X = a + ( b − a )U1 Y = cU2 3. If Y ≤ f ( X ) , then accept X as the random variate. Otherwise, reject the point and go back to step 1. f (x) 0.4 0 1 2 34 x 12 ACCEPTANCE-REJECTION TECHNIQUE f (x) 0.4 0 1 2 34 x Note that for the given picture, a=1, b=4, c=0.4. All the generated X values between 1 and 2 will be accepted whereas only 75% of the points between 2 and 4 will be accepted. Therefore, the empirical p.d.f. will resemble f(x). 13 ACCEPTANCE-REJECTION TECHNIQUE The procedure can also be rewritten as follows: Specify a function t(x) which envelops the p.d.f. f(x). That is, t( x) ≥ f ( x) for all x Note that t(x) is not a p.d.f. but it can be converted into a p.d.f. r(x) where c= ∞ r( x ) = t (x ) / c ∫ t ( x )dx −∞ 1. Generate Y with p.d.f. r(y), 2. Generate U ~ Uniform(0,1) 3. If U ≤ f (Y ) / t (Y ) , set X=Y. Otherwise, go back to 1 and 14 repeat. POISSON VARIATE GENERATION −λ eλ P ( N = n) = , n! n n = 0, 1, 2, ... If the arrival process is Poisson with mean λ, then the interarrival times (Ai’s) are exponential with rate λ. N = n iff A1 + A2 + ... + An ≤ 1 < A1 + A2 + ... + An + An +1 A1 0 A2 ... An+1 An 1 time N=n arrivals occur during a unit time interval (0,1] 15 POISSON VARIATE GENERATION A1 + A2 + ... + An ≤ 1 < A1 + A2 + ... + An + An +1 n n +1 1 ∑ − λ ln U i =1 i ≤1< ∑− i =1 n λ ln U i n +1 i =1 1 i =1 ln ∏ U i ≥ −λ > ln ∏ U i n ∏U i =1 i ≥e −λ n +1 > ∏U i i =1 16 NORMAL VARIATE GENERATION X ~ Normal ( µ , σ ) 2 Let Z be a standard normal random variable Z= X −µ σ Z ~ Normal (0,1) Given a standard normal random variate, X can be obtained. X = µ +σ Z Question: How to generate Z? 17 NORMAL VARIATE GENERATION Using Central Limit Theorem (CLT): Let 12 S12 = ∑ U i where U i ~ Uniform(0,1) i =1 Then E( S12 ) = 12 * 0.5 = 6 Var ( S12 ) = 12 * 1 =1 12 S12 ~ Normal (6,1) Z = S12 − 6 • • Z is approximately Normal(0,1). One standard normal random variate is obtained using 12 Uniform r.v. 18 NORMAL VARIATE GENERATION Box and Muller method (1958) Consider two standard normal normal random variables, Z1 and Z2 which are represented in polar coordinates as Z1 = B cos θ Z2 = B sin θ Z i ~ Normal (0,1) i = 1,2 B = Z + Z ~ Chi − Square(υ = 2) 2 2 1 2 2 Chi − Square(υ = 2) = Exponential ( Mean = 2) θ ~ Uniform(0,2π ) 19 NORMAL VARIATE GENERATION 1. Generate U1 and U2. 2. Compute B = ( −2ln U1 ) , θ = 2πU2 3. Set Z1 = B cos θ , Z2 = B sin θ Z2 B Θ Z1 20 ...
View Full Document

This note was uploaded on 07/30/2009 for the course INDUSTRIAL ie306 taught by Professor Alirizakaylan during the Spring '09 term at Boğaziçi University.

Ask a homework question - tutors are online