Lecture 19 Nov10, 2010 Discrete event simulation (Ross) discrete and continuous distributions computationally generating random variable following various.

Slides:



Advertisements
Similar presentations
Special random variables Chapter 5 Some discrete or continuous probability distributions.
Advertisements

Let X 1, X 2,..., X n be a set of independent random variables having a common distribution, and let E[ X i ] = . then, with probability 1 Strong law.
Exponential Distribution. = mean interval between consequent events = rate = mean number of counts in the unit interval > 0 X = distance between events.
Chapter 5 Some Important Discrete Probability Distributions
Chapter 5 Discrete Random Variables and Probability Distributions
Basic Business Statistics, 11e © 2009 Prentice-Hall, Inc. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Basic Business Statistics.
ฟังก์ชั่นการแจกแจงความน่าจะเป็น แบบไม่ต่อเนื่อง Discrete Probability Distributions.
Statistics for Managers Using Microsoft Excel, 4e © 2004 Prentice-Hall, Inc. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Statistics.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Pearson Prentice-Hall, Inc.Chap 5-1 Statistics for Managers Using Microsoft® Excel 5th Edition.
Lec 18 Nov 12 Probability – definitions and simulation.
Chapter 4 Discrete Random Variables and Probability Distributions
Descriptive statistics Experiment  Data  Sample Statistics Sample mean Sample variance Normalize sample variance by N-1 Standard deviation goes as square-root.
Random-Variate Generation. Need for Random-Variates We, usually, model uncertainty and unpredictability with statistical distributions Thereby, in order.
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
Descriptive statistics Experiment  Data  Sample Statistics Experiment  Data  Sample Statistics Sample mean Sample mean Sample variance Sample variance.
Statistics for Managers Using Microsoft Excel, 4e © 2004 Prentice-Hall, Inc. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Statistics.
Chapter 5 Discrete and Continuous Probability Distributions
Some standard univariate probability distributions
A random variable that has the following pmf is said to be a binomial random variable with parameters n, p The Binomial random variable.
Chap 5-1 Copyright ©2012 Pearson Education, Inc. publishing as Prentice Hall Chap 5-1 Chapter 5 Discrete Probability Distributions Basic Business Statistics.
Class notes for ISE 201 San Jose State University
Statistics for Managers Using Microsoft® Excel 5th Edition
Chapter 21 Random Variables Discrete: Bernoulli, Binomial, Geometric, Poisson Continuous: Uniform, Exponential, Gamma, Normal Expectation & Variance, Joint.
4-1 Continuous Random Variables 4-2 Probability Distributions and Probability Density Functions Figure 4-1 Density function of a loading on a long,
CMPE 252A: Computer Networks Review Set:
McGraw-Hill/IrwinCopyright © 2009 by The McGraw-Hill Companies, Inc. All Rights Reserved. Chapter 4 and 5 Probability and Discrete Random Variables.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Discrete Random Variables Chapter 4.
CA200 Quantitative Analysis for Business Decisions.
Standard Statistical Distributions Most elementary statistical books provide a survey of commonly used statistical distributions. The reason we study these.
 1  Outline  stages and topics in simulation  generation of random variates.
CPSC 531: Probability Review1 CPSC 531:Distributions Instructor: Anirban Mahanti Office: ICT Class Location: TRB 101.
Lecture 17 Nov 7, 2012 Discrete event simulation discrete time systems system changes with time, in discrete steps uncertainty (modeled by probability)
Chapter 5 Statistical Models in Simulation
Tch-prob1 Chap 3. Random Variables The outcome of a random experiment need not be a number. However, we are usually interested in some measurement or numeric.
Modeling and Simulation CS 313
PROBABILITY & STATISTICAL INFERENCE LECTURE 3 MSc in Computing (Data Analytics)
Statistics for Engineer Week II and Week III: Random Variables and Probability Distribution.
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc.. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Basic Business Statistics.
Random Sampling, Point Estimation and Maximum Likelihood.
Ch5 Continuous Random Variables
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc.. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Basic Business Statistics.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics Michael Baron. Probability and Statistics for Computer Scientists,
JMB Chapter 5 Part 2 EGR Spring 2011 Slide 1 Multinomial Experiments  What if there are more than 2 possible outcomes? (e.g., acceptable, scrap,
McGraw-Hill/IrwinCopyright © 2009 by The McGraw-Hill Companies, Inc. All Rights Reserved. Chapter 5 Discrete Random Variables.
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 25 Simulation.
Stats Probability Theory Summary. The sample Space, S The sample space, S, for a random phenomena is the set of all possible outcomes.
Exam 2: Rules Section 2.1 Bring a cheat sheet. One page 2 sides. Bring a calculator. Bring your book to use the tables in the back.
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.
IE 300, Fall 2012 Richard Sowers IESE. 8/30/2012 Goals: Rules of Probability Counting Equally likely Some examples.
Lec. 08 – Discrete (and Continuous) Probability Distributions.
Random Variables Example:
Chapter 4. Random Variables - 3
Business Statistics: A Decision-Making Approach, 7e © 2008 Prentice-Hall, Inc. Chap 5-1 Business Statistics: A Decision-Making Approach 7 th Edition Chapter.
Copyright © 2011 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Chapter 5 Discrete Random Variables.
Engineering Probability and Statistics - SE-205 -Chap 3 By S. O. Duffuaa.
Chap 5-1 Chapter 5 Discrete Random Variables and Probability Distributions Statistics for Business and Economics 6 th Edition.
Chap 5-1 Discrete and Continuous Probability Distributions.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics B: Michael Baron. Probability and Statistics for Computer Scientists,
Chapter Five The Binomial Probability Distribution and Related Topics
MECH 373 Instrumentation and Measurements
Math 4030 – 4a More Discrete Distributions
Probability Distributions: a review
Random variables (r.v.) Random variable
Engineering Probability and Statistics - SE-205 -Chap 3
Chapter 5 Statistical Models in Simulation
Discrete event simulation discrete time systems
Probability Review for Financial Engineers
Some Discrete Probability Distributions Part 2
Chapter 3 : Random Variables
Multinomial Experiments
Presentation transcript:

Lecture 19 Nov10, 2010 Discrete event simulation (Ross) discrete and continuous distributions computationally generating random variable following various distributions. repair problem

Exercise 2: (coupon collector’s problem) When you buy a can of soda, it contains a coupon with a label in 1:n. The labels on the can are random in the sense that, at any point during simulation, the probability that the next can you buy will contain label j is 1/n. The goal is the determine the average number of cans you need to buy before you have collected all the n coupons. Idea: create an array A of size n, all set to 0. Create another array to keep track of the number of cans to buy before all n coupons are collected. The size of this array B is m = the number of trials. Repeat generating a random number j in 1:n, and increment A(j) until all A(j) are > 0. At this point, set B(k) to sum(A) and repeat fro k = 1, 2, …, m.

Probability distributions In a Discrete Event Simulation, you need to decide what probability distribution functions best model the events. in most situations, uniform distribution does not work. Pseudorandom number generators generate numbers in a uniform distribution One basic trick is to transform that uniform distribution into other distributions. Some standard probability distributions are convenient to represent mathematically. They may or may not represent reality, but can be useful simplification.

Mean and Variance of a Discrete Random Variable

Example:

Mean and Variance of a Discrete Random Variable Expected Value of a Function of a Discrete Random Variable

Discrete Uniform Distribution Definition

Discrete Uniform Distribution Example:

Discrete Uniform Distribution Probability mass function for a discrete uniform random variable.

Discrete Uniform Distribution Mean and Variance

Binomial Distribution Random experiments and random variables

Binomial Distribution Definition

Binomial Distribution Binomial distributions for selected values of n and p.

Binomial Distribution Example:

Binomial Distribution Example

Binomial Distribution Mean and Variance

Geometric and Negative Binomial Distributions Example

Geometric Distribution Definition

Geometric Distribution Definition

Poisson distribution X follows a Poisson distribution if:

Normal or Gaussian distribution  Ubiquitous in statistics  Many phenomena follow this distribution  When an experiment is repeated, the sum of the outcomes tend to be normally distributed.  We can test this experimentally using a Matlab simulation.

Normal Distribution Normal probability density functions for selected values of the parameters  and  2.

Normal Distribution Some useful results concerning the normal distribution

Normal Distribution Definition : Standard Normal

Exponential Distribution

Simulating a Probability distribution Sampling values from an observational distribution with a given set of probabilities (“discrete inverse transform method”). Suppose the distribution we want to simulate is X where p(X = x 1 ) = p 0, p(X = x 2 ) = p 1, …, p(X = x n ) = p n-1 Generate a random number U If U < p 0 return X 1 If U < p 0 + p 1 return X 2 If U < p 0 + p 1 + p 2 return X 3 etc. This can be speeded up by sorting p so that the larger intervals are processed first, reducing the number of steps.

Poisson distribution Example of algorithm to sample from a distribution. X follows a Poisson distribution if: An algorithm for sampling from a Poisson distribution: 1. Generate a random number U 2. If i=0, p=e -l, F=p 3. If U < F, return I 4. P = l * p / (i + 1), F = F + p, i = i Go to 3 There are similar tricks to sampling from other probability distributions. Some of the distributions (e.g. Poisson, Normal etc.) can be generated using Matlab’s built-in functions.

Input: N = the number of machines needed to run the system S = the number of spare machines P1 = the distribution of failure time of a machine P2 = the probability distribution of the time to service a faulty machine Output: The time at which the system crashes. To get the average time between successive crashes, we should repeat the simulation many times and sum the times, divide by the number of trials.

Algorithm for simulation Variables used: time – t, system variable – r: the number of machines down at time t. An event occurs when a machine fails or a machine has been repaired. Event list: t j is the time at which the j-th machine currently in use will fail. t* is the time at which the present machine being repaired will be ready for use, t* = if no such machine.

function T = simulate_repair(n, s, l1, l2) % simulation of a repair problem % F = prob distribution defining failure of machine, i.e., % F(t) = prob(time taken for machine to break down = t) % G = prob distribution defining the time taken to repair % ie., G(t) = prob(time taken to repair = t) % n = number of machines, s = additional number of machines % goal is to compute time T at which the sytem fails % system fails when more than s machines are in repair % failure rate is a uniform distribution with values 1, 2,..., l1 % repair time follows a uniform distribution in [1, l2] t = 0; r = 0; tstar = Inf; mqueue = []; for j=1:n mqueue(end+1) = uniform(l1); end; mqueue(end+1)=tstar; mqueue = sort(mqueue); Simulation function – based on algorithm from Ross’s book (Chapter 6)

while 1 t1 = mqueue(1); if t1 < tstar t = mqueue(1); r = r + 1; if r == s+1 T = t; return; else x = uniform(l1); mqueue(end+1)=t+x; mqueue = mqueue(2:end); mqueue = sort(mqueue); end; if r == 1 y = uniform(l2); tstar = t+y; end; else t = tstar; r = r - 1; if r == 0 tstar = Inf; else y = uniform(l2); tstar = t + y; end;

It is easy to modify the code so that the distributions (for failure time and repair time) are not uniform, but say Poisson, exponential or normal etc. Exercise: Try replacing uniform by Poisson or exponential and compute the expected time for crash. Does it increase the expected time before the system crashes (given the same mean)?

Service queue simulation Problem: Each customer joins a queue serviced by a single server. The arrival time of the customer is a random number given by a known distribution. Time to service obeys a known (possibly different) probability distribution. Assume that there are a total of N customers. (N is known.) Goal is to calculate the average time a customer has to wait in the service line? We may also want to calculate the average waiting time of the k-th customer. Variations: 1) assume that after some time T, no additional customer allowed. 2) There are two service providers.

Simulation of a car wash system