Download presentation
Presentation is loading. Please wait.
1
28-1 ©2006 Raj Jain www.rajjain.com Random Variate Generation
2
28-2 ©2006 Raj Jain www.rajjain.com Overview 1.Inverse transformation 2.Rejection 3.Composition 4.Convolution 5.Characterization
3
28-3 ©2006 Raj Jain www.rajjain.com Random-Variate Generation General Techniques Only a few techniques may apply to a particular distribution Look up the distribution in Chapter 29
4
28-4 ©2006 Raj Jain www.rajjain.com Inverse Transformation Used when F -1 can be determined either analytically or empirically. 0 0.5 u 1.0 x CDF F(x)
5
28-5 ©2006 Raj Jain www.rajjain.com Proof
6
28-6 ©2006 Raj Jain www.rajjain.com Example 28.1 For exponential variates: If u is U(0,1), 1-u is also U(0,1) Thus, exponential variables can be generated by:
7
28-7 ©2006 Raj Jain www.rajjain.com Example 28.2 The packet sizes (trimodal) probabilities: The CDF for this distribution is:
8
28-8 ©2006 Raj Jain www.rajjain.com Example 28.2 (Cont) The inverse function is: Note: CDF is continuous from the right the value on the right of the discontinuity is used The inverse function is continuous from the left u=0.7 x=64
9
28-9 ©2006 Raj Jain www.rajjain.com Applications of the Inverse-Transformation Technique
10
28-10 ©2006 Raj Jain www.rajjain.com Rejection Can be used if a pdf g(x) exists such that c g(x) majorizes the pdf f(x) c g(x) > f(x) 8 x Steps: 1. Generate x with pdf g(x). 2. Generate y uniform on [0, cg(x)]. 3. If y f(x) Efficiency = how closely c g(x) envelopes f(x) Large area between c g(x) and f(x) Large percentage of (x, y) generated in steps 1 and 2 are rejected If generation of g(x) is complex, this method may not be efficient.
11
28-11 ©2006 Raj Jain www.rajjain.com Example 28.2 Beta(2,4) density function: Bounded inside a rectangle of height 2.11 Steps: Generate x uniform on [0, 1]. Generate y uniform on [0, 2.11]. If y < 20 x(1-x) 3, then output x and return. Otherwise repeat from step 1.
12
28-12 ©2006 Raj Jain www.rajjain.com Composition Can be used if CDF F(x) = Weighted sum of n other CDFs. Here,, and F i 's are distribution functions. n CDFs are composed together to form the desired CDF Hence, the name of the technique. The desired CDF is decomposed into several other CDFs Also called decomposition. Can also be used if the pdf f(x) is a weighted sum of n other pdfs:
13
28-13 ©2006 Raj Jain www.rajjain.com Steps: Generate a random integer I such that: This can easily be done using the inverse- transformation method. Generate x with the ith pdf f i (x) and return.
14
28-14 ©2006 Raj Jain www.rajjain.com Example 28.4 pdf: Composition of two exponential pdf's Generate If u 1 <0.5, return; otherwise return x=a ln u 2. Inverse transformation better for Laplace
15
28-15 ©2006 Raj Jain www.rajjain.com Convolution Sum of n variables: Generate n random variate y i 's and sum For sums of two variables, pdf of x = convolution of pdfs of y 1 and y 2. Hence the name Although no convolution in generation If pdf or CDF = Sum Composition Variable x = Sum Convolution
16
28-16 ©2006 Raj Jain www.rajjain.com Convolution: Examples Erlang-k = i=1 k Exponential i Binomial(n, p) = i=1 n Bernoulli(p) Generated n U(0,1), return the number of RNs less than p ( ) = i=1 N(0,1) 2 a, b )+ (a,b 2 )= (a,b 1 +b 2 ) Non-integer value of b = integer + fraction n Any = Normal U(0,1) Normal m Geometric = Pascal 2 Uniform = Triangular
17
28-17 ©2006 Raj Jain www.rajjain.com Characterization Use special characteristics of distributions characterization Exponential inter-arrival times Poisson number of arrivals Continuously generate exponential variates until their sum exceeds T and return the number of variates generated as the Poisson variate. The a th smallest number in a sequence of a+b+1 U(0,1) uniform variates has a (a, b) distribution. The ratio of two unit normal variates is a Cauchy(0, 1) variate. A chi-square variate with even degrees of freedom 2 ( ) is the same as a gamma variate (2, /2). If x 1 and x 2 are two gamma variates (a,b) and (a,c), respectively, the ratio x 1 /(x 1 +x 2 ) is a beta variate (b,c). If x is a unit normal variate, e + x is a lognormal( , ) variate.
18
28-18 ©2006 Raj Jain www.rajjain.com Summary Is pdf a sum of other pdfs? Use Composition Yes Is CDF a sum of other CDFs? Use composition Yes Is CDF invertible? Use inversion Yes
19
28-19 ©2006 Raj Jain www.rajjain.com Summary (Cont) Does a majorizing function exist? Use rejection Yes Is the variate related to other variates? Use characterization Yes Is the variate a sum of other variates Use convolution Yes Use empirical inversion No
20
28-20 ©2006 Raj Jain www.rajjain.com Exercise 28.1 A random variate has the following triangular density: Develop algorithms to generate this variate using each of the following methods: a.Inverse-transformation b.Rejection c.Composition d.Convolution
21
28-21 ©2006 Raj Jain www.rajjain.com Homework A random variate has the following triangular density: Develop algorithms to generate this variate using each of the following methods: a.Inverse-transformation b.Rejection c.Composition d.Convolution
22
28-22 ©2006 Raj Jain www.rajjain.com Answer to Homework A random variate has the following triangular density: Develop algorithms to generate this variate using each of the following methods: a.Inverse-transformation F(x) = a.Rejection b.Composition c.Convolution
23
28-23 ©2006 Raj Jain www.rajjain.com Inverse Transformation 048 x x F(x) 048 x f(x) x/16(8-x)/16 0.25
24
28-24 ©2006 Raj Jain www.rajjain.com Rejection Find a majoring function: f(x) < cg(x) Generate x with g(x) and generate y uniform on (0,cg(x)) If y < f(x), then output x and return. Otherwise, repeat from step 1. g(x) = 1/8 0<x<8, c=2 Generate x with U(0,8) and y with U(0,0.25) if y<(1/16)min(x,8-x) output x, otherwise repeat 048 x f(x) x/16(8-x)/16 0.25
25
28-25 ©2006 Raj Jain www.rajjain.com Composition Can be used if the pdf f(x) is a weighted sum of n other pdfs: 048 x f(x) x/16 1/4 048 x f(x) (8-x)/16 1/4 Generate u1 = U(0,1), if u1 0.5 use right triangle to generate x Left Triangle: f(x)=x/16 => F(x)=x 2 /32=u => Right Triangle: f(x)=(8-x)/16 F(x)=x-x 2 /32=u
26
28-26 ©2006 Raj Jain www.rajjain.com Convolution Sum of n variables: Generate n random variate y i 's and sum Triangle is a convolution of two squares 04u1 f(x) 1/4 04u2 f(x) 1/4 048 x f(x) 0.25 Generate u1=U(0,4) Generate u2=U(0,4) Return x=u1+u2
27
28-27 ©2006 Raj Jain www.rajjain.com Thank You!
28
28-28 ©2006 Raj Jain www.rajjain.com Copyright Notice These slides have been provided to instructors using “The Art of Computer Systems Performance Analysis” as the main textbook in their course or tutorial. Any other use of these slides is prohibited. Instructors are allowed to modify the content or templates of the slides to suite their audience. The copyright notice on every slide and this copyright slide should not be removed when these slides’ content or templates are modified. These slides or their modified versions are not transferable to other instructors without their agreeing with these conditions directly with the author.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.