Stochastic Simulation APPM 7400
Total Page:16
File Type:pdf, Size:1020Kb
Stochastic Simulation APPM 7400 Lesson 5: Generating (Some) Continuous Random Variables September 12, 2018 Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 1 / 1 Furthermore, suppose that you can invert F . If U ∼ unif (0; 1), the random variable F −1(U) has the same distribution as X ! Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 2 / 1 If U ∼ unif (0; 1), the random variable F −1(U) has the same distribution as X ! Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). Furthermore, suppose that you can invert F . Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 2 / 1 Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). Furthermore, suppose that you can invert F . If U ∼ unif (0; 1), the random variable F −1(U) has the same distribution as X ! Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 2 / 1 = P(U ≤ F (x)) = F (x) = P(X ≤ x) F non-decreasing + cdf of unif(0,1) definition of F F −1 non-decreasing Generating Continuous Random Variables Proof: P(F −1(U) ≤ x) Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 3 / 1 = F (x) = P(X ≤ x) cdf of unif(0,1) definition of F Generating Continuous Random Variables Proof: P(F −1(U) ≤ x) = P(U ≤ F (x)) F non-decreasing + F −1 non-decreasing Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 3 / 1 = P(X ≤ x) definition of F Generating Continuous Random Variables Proof: P(F −1(U) ≤ x) = P(U ≤ F (x)) = F (x) F non-decreasing + cdf of unif(0,1) F −1 non-decreasing Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 3 / 1 Generating Continuous Random Variables Proof: P(F −1(U) ≤ x) = P(U ≤ F (x)) = F (x) = P(X ≤ x) F non-decreasing + cdf of unif(0,1) definition of F F −1 non-decreasing Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 3 / 1 + R x −λu −λx cdf: F (x) = 0 λe du = 1 − e ; x ≥ 0 + −1 1 Now plug in F (x) = − λ ln(1 − x) a uniform! Generating Continuous Random Variables Example: Generating exponential rate λ r.v.'s: pdf: f (x) = λe−λx ; x ≥ 0 Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 4 / 1 + −1 1 Now plug in F (x) = − λ ln(1 − x) a uniform! Generating Continuous Random Variables Example: Generating exponential rate λ r.v.'s: pdf: f (x) = λe−λx ; x ≥ 0 + R x −λu −λx cdf: F (x) = 0 λe du = 1 − e ; x ≥ 0 Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 4 / 1 Now plug in a uniform! Generating Continuous Random Variables Example: Generating exponential rate λ r.v.'s: pdf: f (x) = λe−λx ; x ≥ 0 + R x −λu −λx cdf: F (x) = 0 λe du = 1 − e ; x ≥ 0 + −1 1 F (x) = − λ ln(1 − x) Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 4 / 1 Generating Continuous Random Variables Example: Generating exponential rate λ r.v.'s: pdf: f (x) = λe−λx ; x ≥ 0 + R x −λu −λx cdf: F (x) = 0 λe du = 1 − e ; x ≥ 0 + −1 1 Now plug in F (x) = − λ ln(1 − x) a uniform! Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 4 / 1 Generating Continuous Random Variables Results: (100,000 values, λ = 3:5) Density 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 sample Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 5 / 1 There is no closed form expression for the cdf! Generating Continuous Random Variables The Standard Normal Distribution: 1 − 1 x2 f (x) = p e 2 ; −∞ < x < 1 2π Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 6 / 1 Generating Continuous Random Variables The Standard Normal Distribution: 1 − 1 x2 f (x) = p e 2 ; −∞ < x < 1 2π There is no closed form expression for the cdf! Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 6 / 1 Then p X1 = −2 ln U1 cos(2πU2) is normally distributed with mean0 and variance1. So is p X2 = −2 ln U1 sin(2πU2) and X1 and X2 are independent! Generating Continuous Random Variables The Box-Muller Transformation: Let U1 and U2 be independent unif (0; 1) r.v.'s. Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 7 / 1 So is p X2 = −2 ln U1 sin(2πU2) and X1 and X2 are independent! Generating Continuous Random Variables The Box-Muller Transformation: Let U1 and U2 be independent unif (0; 1) r.v.'s. Then p X1 = −2 ln U1 cos(2πU2) is normally distributed with mean0 and variance1. Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 7 / 1 and X1 and X2 are independent! Generating Continuous Random Variables The Box-Muller Transformation: Let U1 and U2 be independent unif (0; 1) r.v.'s. Then p X1 = −2 ln U1 cos(2πU2) is normally distributed with mean0 and variance1. So is p X2 = −2 ln U1 sin(2πU2) Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 7 / 1 Generating Continuous Random Variables The Box-Muller Transformation: Let U1 and U2 be independent unif (0; 1) r.v.'s. Then p X1 = −2 ln U1 cos(2πU2) is normally distributed with mean0 and variance1. So is p X2 = −2 ln U1 sin(2πU2) and X1 and X2 are independent! Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 7 / 1 If neither of these apply to your simulation problem, move on to the next algorithm. It requires that you be able to uniformly bound the \target pdf" by an integrable function. If you can't do that, move on to the next algorithm... there is no \catch-all" procedure so we'd better build up a big arsenal of simulation techniques! Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 8 / 1 It requires that you be able to uniformly bound the \target pdf" by an integrable function. If you can't do that, move on to the next algorithm... there is no \catch-all" procedure so we'd better build up a big arsenal of simulation techniques! Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 8 / 1 If you can't do that, move on to the next algorithm... there is no \catch-all" procedure so we'd better build up a big arsenal of simulation techniques! Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. It requires that you be able to uniformly bound the \target pdf" by an integrable function. Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 8 / 1 Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. It requires that you be able to uniformly bound the \target pdf" by an integrable function. If you can't do that, move on to the next algorithm... there is no \catch-all" procedure so we'd better build up a big arsenal of simulation techniques! Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 8 / 1 want to simulate a r.v. X with pdf f need to find another function g so that g(x) ≥ f (x) 8x normalize g to a pdf 1 h(x) = g(x) c where c = R g(x) dx Generating Continuous Random Variables Accept/Reject Algorithm: (due to von Neumann) Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 9 / 1 need to find another function g so that g(x) ≥ f (x) 8x normalize g to a pdf 1 h(x) = g(x) c where c = R g(x) dx Generating Continuous Random Variables Accept/Reject Algorithm: (due to von Neumann) want to simulate a r.v. X with pdf f Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 9 / 1 normalize g to a pdf 1 h(x) = g(x) c where c = R g(x) dx Generating Continuous Random Variables Accept/Reject Algorithm: (due to von Neumann) want to simulate a r.v. X with pdf f need to find another function g so that g(x) ≥ f (x) 8x Lesson 5: Generating (Some) Continuous Random VariablesStochastic Simulation September 12, 2018 9 / 1 Generating Continuous Random Variables Accept/Reject Algorithm: (due to von Neumann) want to simulate a r.v.