Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC 531:Random-Variate Generation

Similar presentations


Presentation on theme: "CPSC 531:Random-Variate Generation"— Presentation transcript:

1 CPSC 531:Random-Variate Generation
Instructor: Anirban Mahanti Office: ICT 745 Class Location: TRB 101 Lectures: TR 15:30 – 16:45 hours Class web page: Notes from “Simulation” by Sheldon Ross, Academic Press, 2002. CPSC 531: RV Generation

2 Outline Talk about generating both discrete and continuous random variates Inverse Transform Method (focus on this one) The Rejection Method The Composition Method First consider the Inverse Transform Method Discrete Random Variates Continuous Random Variate CPSC 531: RV Generation

3 Discrete Random Variates
Suppose we want to generate the value of a discrete random variable X that has the following probability mass function The Inverse Transform Method is as follows: Generate u = U(0,1) and set X as follows: CPSC 531: RV Generation

4 Discrete Random Variate Algorithm
Generate u=U(0,1) If u<p0, set X=x0, return; If u<p0+p1, set X=x1, return; After generating a random number u, we find the value of X by determining the interval [F(xj-1),F(xj)] in which u lies. That is, the inverse of F(u) is determined. Time complexity of generating a random variable is proportional to the number of intervals to be searched. CPSC 531: RV Generation

5 Example Assume p1= 0.2, p2 = 0.1, p3 = 0.25, p4 = Determine RNG such that P{X=j} = pj? Version 1 Generate u=U(0,1) If u<0.2, set X=1, return; If u<0.3, set X=2, return; If u<0.55, set X=3, return; Set X=4, return; Version 2 (efficient) Generate u=U(0,1) If u<0.45, set X=4, return; If u<0.7, set X=3, return; If u<0.9, set X=1, return; Set X=2, return; CPSC 531: RV Generation

6 Geometric Random Variables
X is a geometric random variable with parameter p if it has the following probability mass function: Generate value of X by generating random number u and setting X to j such that: 1 - qj-1 ≤ u < 1 – qj CPSC 531: RV Generation

7 Geometric Random Variables
Note that 1 - qj-1 ≤ u < 1 – qj is equivalent to qj < 1 - u ≤ qj-1 Therefore, X = min{j: qj < 1 – u} CPSC 531: RV Generation

8 Generating Poisson Random Variables
Poisson Distribution with rate λ. Poisson RV Algorithm (λ) 1. Generate u=U(0,1); 2. i=0, p = e-λ, F=p; 3. if u < F, set X = i and return; 4. p= λp/(i+1), F = F+p, i=i+1; 5. Go to step 3; CPSC 531: RV Generation

9 Generating Binomial Random Variables
X is Binomial random variable with parameters n and p Binomial RV Algorithm (n, p) 1. Generate u=U(0,1); 2. c=p/(1-p), i=0, d=(1-p)n, F=d 3. if u < F, set X = i and return; 4. d=[c(n-i)/(i+1)]d, F=F+d, i=i+1; 5. Go to step 3; CPSC 531: RV Generation

10 Inverse Transform Method
Let r be a uniform (0, 1) random variable. For any continuous distribution F the random variable X defined by X=F-1(r) has distribution F. r1 x1 r = F(x) CPSC 531: RV Generation

11 Exponential Distribution [BCNN05]
Exponential cdf: To generate X1, X2, X3 … r = F(x) = 1 – e-lx for x ³ 0 Xi = F-1(Ri) = -(1/l) ln(1-Ri) [Eq’n 8.3] where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X) Figure: Inverse-transform technique for exp(l = 1) CPSC 531: RV Generation

12 Other Examples We will work out the following on the board:
Uniform in the interval [a,b] Weibull Distribution CPSC 531: RV Generation

13 Rejection technique [BCNN05]
Useful particularly when inverse cdf does not exist in closed 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 minimize the number of rejections. Generate R Condition Output R’ yes no 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 CPSC 531: RV Generation

14 NSPP [BCNN05] Non-stationary Poisson Process (NSPP): a Possion arrival process with an arrival rate that varies with time Idea behind thinning: Generate a stationary Poisson arrival process at the fastest rate, l* = max l(t) But “accept” only a portion of arrivals, thinning out just enough to get the desired time-varying rate Generate E ~ Exp(l*) t = t + E no Condition R <= l(t) yes Output E ’~ t CPSC 531: RV Generation

15 NSPP [BCNN05] Example: Generate a random variate for a NSPP
Data: Arrival Rates Procedures: Step 1. l* = max l(t) = 1/5, t = 0 and i = 1. Step 2. For random number R = , E = -5ln(0.213) = 13.13 t = 13.13 Step 3. Generate R = l(13.13)/l*=(1/15)/(1/5)=1/3 Since R>1/3, do not generate the arrival Step 2. For random number R = , E = -5ln(0.553) = 2.96 t = = 16.09 Step 3. Generate R = l(16.09)/l*=(1/15)/(1/5)=1/3 Since R<1/3, T1 = t = 16.09, and i = i + 1 = 2 CPSC 531: RV Generation

16 Special Properties Based on features of particular family of probability distributions For example: Direct Transformation for normal and lognormal distributions Convolution Beta distribution (from gamma distribution) CPSC 531: RV Generation

17 Direct Transformation [BCNN05]
Approach for normal(0,1): Consider two standard normal random variables, Z1 and Z2, plotted as a point in the plane: B2 = Z21 + Z22 ~ chi-square distribution with 2 degrees of freedom = Exp(l = 2). Hence, The radius B and angle f are mutually independent. In polar coordinates: Z1 = B cos f Z2 = B sin f CPSC 531: RV Generation

18 Direct Transformation [BCNN05]
Approach for normal(m,s2): Generate Zi ~ N(0,1) Approach for lognormal(m,s2): Generate X ~ N((m,s2) Xi = m + s Zi Yi = eXi CPSC 531: RV Generation

19 Summary Principles of random-variate generate via
Inverse-transform technique Acceptance-rejection technique Special properties Important for generating continuous and discrete distributions CPSC 531: RV Generation


Download ppt "CPSC 531:Random-Variate Generation"

Similar presentations


Ads by Google