Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 5.2: Simulation of Random Variables CIS 2033. Computational.

Slides:



Advertisements
Similar presentations
Exponential Distribution
Advertisements

CS433: Modeling and Simulation
Joint and marginal distribution functions For any two random variables X and Y defined on the same sample space, the joint c.d.f. is For an example, see.
Lecture 10 – Introduction to Probability Topics Events, sample space, random variables Examples Probability distribution function Conditional probabilities.
Continuous Random Variables. L. Wang, Department of Statistics University of South Carolina; Slide 2 Continuous Random Variable A continuous random variable.
Review.
Probability Distributions
Today Today: Chapter 5 Reading: –Chapter 5 (not 5.12) –Suggested problems: 5.1, 5.2, 5.3, 5.15, 5.25, 5.33, 5.38, 5.47, 5.53, 5.62.
Probability Distributions Random Variables: Finite and Continuous Distribution Functions Expected value April 3 – 10, 2003.
C4: DISCRETE RANDOM VARIABLES CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics Longin Jan Latecki.
Chapter 4: Joint and Conditional Distributions
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics, 2007 Instructor Longin Jan Latecki Chapter 7: Expectation and variance.
Lecture 10 – Introduction to Probability Topics Events, sample space, random variables Examples Probability distribution function Conditional probabilities.
1 Exponential Distribution & Poisson Process Memorylessness & other exponential distribution properties; Poisson process and compound P.P.’s.
Random Variables and Probability Distributions
5-2 Probability Distributions This section introduces the important concept of a probability distribution, which gives the probability for each value of.
Starter The probability distribution of a discrete random variable X is given by: P(X = r) = 30kr for r = 3, 5, 7 P(X = r) = 0 otherwise What is the value.
Exponential Distribution
Modeling and Simulation CS 313
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Review and Preview This chapter combines the methods of descriptive statistics presented in.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Lecture Slides Elementary Statistics Twelfth Edition and the Triola Statistics Series.
Chapter 3 Random Variables and Probability Distributions 3.1 Concept of a Random Variable: · In a statistical experiment, it is often very important to.
Random Variables. A random variable X is a real valued function defined on the sample space, X : S  R. The set { s  S : X ( s )  [ a, b ] is an event}.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics Michael Baron. Probability and Statistics for Computer Scientists,
MAT 1235 Calculus II Section 8.5 Probability
ENGG 2040C: Probability Models and Applications Andrej Bogdanov Spring Jointly Distributed Random Variables.
One Random Variable Random Process.
Generalized Semi- Markov Processes (GSMP). Summary Some Definitions The Poisson Process Properties of the Poisson Process  Interarrival times  Memoryless.
MATH 3033 based on Dekking et al. A Modern Introduction to Probability and Statistics Slides by Sean Hercus Instructor Longin Jan Latecki Ch. 6 Simulations.
Probability Refresher COMP5416 Advanced Network Technologies.
Random Variable The outcome of an experiment need not be a number, for example, the outcome when a coin is tossed can be 'heads' or 'tails'. However, we.
The Practice of Statistics, 5th Edition Starnes, Tabor, Yates, Moore Bedford Freeman Worth Publishers CHAPTER 6 Random Variables 6.1 Discrete and Continuous.
Random Variables Example:
Topic 5: Continuous Random Variables and Probability Distributions CEE 11 Spring 2002 Dr. Amelia Regan These notes draw liberally from the class text,
Statistical Estimation Vasileios Hatzivassiloglou University of Texas at Dallas.
AP STATISTICS Section 7.1 Random Variables. Objective: To be able to recognize discrete and continuous random variables and calculate probabilities using.
Stat 35b: Introduction to Probability with Applications to Poker Outline for the day: 1.Uniform, normal, and exponential. 2.Exponential example. 3.Uniform.
Probability Distribution. Probability Distributions: Overview To understand probability distributions, it is important to understand variables and random.
Chapter 9: Joint distributions and independence CIS 3033.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics B: Michael Baron. Probability and Statistics for Computer Scientists,
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 9.1: Parameter estimation CIS Computational Probability.
Computer Simulation Henry C. Co Technology and Operations Management,
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 5.2: Simulation of Random Variables CIS Computational.
Random number generation
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Chapter 3: Discrete Random Variables and Their Distributions CIS.
Umm Al-Qura University
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 11.1: Least squares estimation CIS Computational.
The Poisson Process.
Continuous Random Variables
Cumulative distribution functions and expected values
Chapter Four Random Variables and Their Probability Distributions
Lecture 10 – Introduction to Probability
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 11.1: Least squares estimation CIS Computational.
Multinomial Distribution
Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 9.1: Parameter estimation CIS Computational Probability.
Random-Variate Generation
MATH 3033 based on Dekking et al
STATISTICAL MODELS.
Lecture Slides Elementary Statistics Twelfth Edition
Statistics Lecture 12.
CIS 2033 based on Dekking et al
Random Variables and Probability Distributions
M248: Analyzing data Block A UNIT A3 Modeling Variation.
Lecture Slides Essentials of Statistics 5th Edition
Section 1 – Discrete and Continuous Random Variables
Lesson #5: Probability Distributions
PROBABILITY AND STATISTICS
Lecture Slides Essentials of Statistics 5th Edition
Generating Random Variates
Presentation transcript:

Probability and Statistics for Computer Scientists Second Edition, By: Michael Baron Section 5.2: Simulation of Random Variables CIS 2033. Computational Probability and Statistics Pei Wang

Simulation Simulation: to use a model to study what would happen in the real world Monte Carlo methods: computer simulations involving random numbers Such a method requires values of a random variable with a certain distribution Example: coin tossing before a game Simulation is from Model to Data

Random number generator A device that generates numbers that can be seen as the realization of a random variable Examples: A fair coin is Ber(0.5) A fair die generates {1,2,3,4,5,6} evenly A table of random numbers, Table A1 A program that generates random values

Turn one distribution into another How to generate random numbers of one distribution from those of another? To simulate a fair coin with a fair die To simulate an even distribution on {a,b,c,d} with a fair coin To simulate a fair die with a fair coin To simulate a fair coin with a unfair coin

To get Ber(p) from U(0,1)

Pseudocode Pseudocode describes an algorithm in a semi-formal format Example: Ber(p) u = U(0, 1) if (u < p) return 1 return 0

To generate Bin, Geo, and NegBin Bin(n, p) can be generated using a for-loop to sum n Ber(p) Geo(p) can be generated using a while-loop to count the number of Ber(p) until the first 1 is obtained NegBin(n, p) can be generated using a while-loop to count the number of Ber(p) until the nth 1 is obtained, or a for-loop to sum n Geo(p)

To generate discrete variable A random variable Y has outcomes 1, 3, and 4 with the following probabilities:   P(Y = 1) = 3/5 P(Y = 3) = 1/5 P(Y = 4) = 1/5 How to generate Y from a U(0, 1)? How to generate an arbitrary discrete random variable X, given p(a) or F(a)?

To generate discrete variable (2) Algorithm: 1. Divide [0, 1] according to F(a), that is, 2. Get u = U(0, 1) 3. Generate ai (the ith value) when u is in Ai

To generate continuous variable For a continuous random variable X, if its cdf F strictly increases, then inverse function F-1 exists When F-1 is applied on U that is U(0, 1), event U ≤ F(a) corresponds to event F-1(U) ≤ a So P(F-1(U) ≤ a) = P(U ≤ F(a)) = F(a) Therefore, X can be simulated by F-1(U) To obtain the formula of F-1, solve the equation F(y) = u for y

To generate continuous variable (2) Example: For exponential distribution Exp(λ), if u = F(y) = 1 − e−λy, then y = −(1/λ)ln(1 − u) So the random variable X defined by X = F−1(U) = −(1/λ)ln(1 − U) has an Exp(λ) distribution Since 1 − U is also uniform, it can be replaced by U, so the simulation function is −(1/λ)ln(U)

To generate arbitrary variable The previous solution still works even if the random variable is partly discrete and partly continuous: If F has a jump at b, then P(X = b) is the height of the jump If F is flat at [b, c], then P(X = a) is 0 for any a in [b, c], and F-1 can be made to take any value in [b, c]

To generate arbitrary variable (2)

Rejection method For a continuous random variable, if the cdf F(a) is not available, but the pdf f(a) is, then the latter can be used to generate its values Generating points (X, Y) in a region including f(a), while X any Y are both uniform. Among the points “under f(a)”, i.e., Y < f(X), the X values roughly have the density function f(a) This is an example of Monte Carlo method

Rejection method (2)

Rejection method (3)

Simulation example People waiting to get water from a pump. Let Ti be the inter-arrival time between the ith customer and the previous one, so Customers arrival: T1, T1+T2, T1+T2+T3, ... Their service times: S1, S2, S3, ... The pump capacity v is a model parameter to be determined, and Si = Ri / v for all i, where Ri is the demand of the ith customer.

Simulation example (2) An analysis of the situation leads to the following assumptions: Inter-arrival times: every Ti has an Exp(0.5) distribution (minutes) Service requirement: every Ri has a U(2, 5) distribution (liters) Let Wi be the waiting time of the ith customer: Wi = max{Wi-1 + Si-1 − Ti, 0}.

Simulation example (3)

Simulation example (4)