Hand Simulations. Christos Alexopoulos and Dave Goldsman 9/2/14. Georgia Institute of Technology, Atlanta, GA, USA 1 / 26

Similar documents
ISyE 6644 Fall 2015 Test #1 Solutions (revised 10/5/16)

ISyE 6644 Fall 2016 Test #1 Solutions

ISyE 3044 Fall 2015 Test #1 Solutions

ISyE 3044 Fall 2017 Test #1a Solutions

Queueing Review. Christos Alexopoulos and Dave Goldsman 10/6/16. (mostly from BCNN) Georgia Institute of Technology, Atlanta, GA, USA

Queueing Review. Christos Alexopoulos and Dave Goldsman 10/25/17. (mostly from BCNN) Georgia Institute of Technology, Atlanta, GA, USA

Generating Uniform Random Numbers

Generating Uniform Random Numbers

ISyE 6644 Fall 2014 Test 3 Solutions

ISyE 6644 Fall 2014 Test #2 Solutions (revised 11/7/16)

Generating Uniform Random Numbers

Uniform random numbers generators

Discrete Event and Process Oriented Simulation (2)

Simulation. Where real stuff starts

Monte Carlo Integration. Computer Graphics CMU /15-662, Fall 2016

1.225J J (ESD 205) Transportation Flow Systems

Probability and Statistics Concepts

Queueing Theory and Simulation. Introduction

ISyE 2030 Practice Test 1

Simulation. Where real stuff starts

Lecture 20. Randomness and Monte Carlo. J. Chaudhry. Department of Mathematics and Statistics University of New Mexico

MAS1302 Computational Probability and Statistics

2905 Queueing Theory and Simulation PART IV: SIMULATION

Chapter 2 Queueing Theory and Simulation

2. Conditional Expectation (9/15/12; cf. Ross)

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science

Department of Electrical- and Information Technology. ETS061 Lecture 3, Verification, Validation and Input

The exponential distribution and the Poisson process

Review of Probability. CS1538: Introduction to Simulations

How Monte Carlo Sampling Contributes to Data Analysis. Outline

IEOR 4703: Homework 2 Solutions

h(x) = f(x)/g(x) = (1 + x)e (1/2)x.

Section 1.2: A Single Server Queue

Queueing Theory. VK Room: M Last updated: October 17, 2013.

Computer Networks More general queuing systems

Stochastic Simulation of Communication Networks and their Protocols

CIVL Continuous Distributions

STAT2201. Analysis of Engineering & Scientific Data. Unit 3

An Analysis of the Preemptive Repeat Queueing Discipline

IEOR 6711, HMWK 5, Professor Sigman

2 Random Variable Generation

ISE/OR 762 Stochastic Simulation Techniques

Stochastic Optimization One-stage problem

Introduction to Queueing Theory with Applications to Air Transportation Systems

Simulation Modeling. Random Numbers

Generation of Discrete Random variables

Variance reduction techniques

Continuous Time Processes

Stat 400 section 4.1 Continuous Random Variables


RVs and their probability distributions

Independent Events. Two events are independent if knowing that one occurs does not change the probability of the other occurring

Slides 9: Queuing Models

Random variables. DS GA 1002 Probability and Statistics for Data Science.

Stochastic Simulation of Communication i Networks

EE 368. Weeks 3 (Notes)

Expectation, Variance and Standard Deviation for Continuous Random Variables Class 6, Jeremy Orloff and Jonathan Bloom

Queueing Theory I Summary! Little s Law! Queueing System Notation! Stationary Analysis of Elementary Queueing Systems " M/M/1 " M/M/m " M/M/1/K "

Qualifying Exam CS 661: System Simulation Summer 2013 Prof. Marvin K. Nakayama

Monte Carlo Simulation

Verification and Validation. CS1538: Introduction to Simulations

Math 180A. Lecture 16 Friday May 7 th. Expectation. Recall the three main probability density functions so far (1) Uniform (2) Exponential.

Since D has an exponential distribution, E[D] = 0.09 years. Since {A(t) : t 0} is a Poisson process with rate λ = 10, 000, A(0.

λ, µ, ρ, A n, W n, L(t), L, L Q, w, w Q etc. These

Recitation 2: Probability

Section 7.3: Continuous RV Applications

IEOR 4404: Homework 6

Markov Chains. Chapter 16. Markov Chains - 1

CS115 Computer Simulation Project list

Floyd Bullard January 2008

Chapter 2 SIMULATION BASICS. 1. Chapter Overview. 2. Introduction

Exact Simulation of the Stationary Distribution of M/G/c Queues

Chapter 8 Queuing Theory Roanna Gee. W = average number of time a customer spends in the system.

ISyE 2030 Practice Test 2

Notes on Continuous Random Variables

Chapter 1: Revie of Calculus and Probability

The University of British Columbia Computer Science 405 Practice Midterm Solutions

Queuing Theory. Using the Math. Management Science

Monte Carlo. Lecture 15 4/9/18. Harvard SEAS AP 275 Atomistic Modeling of Materials Boris Kozinsky

Simulation & Modeling Event-Oriented Simulations

Chapter 6 Queueing Models. Banks, Carson, Nelson & Nicol Discrete-Event System Simulation

Waiting time characteristics in cyclic queues

What is a random variable

Generating the Sample

Basic Probability. Introduction

EC611--Managerial Economics

Chapter 5. Statistical Models in Simulations 5.1. Prof. Dr. Mesut Güneş Ch. 5 Statistical Models in Simulations

Exact Simulation of Multivariate Itô Diffusions

STAT 430/510 Probability Lecture 12: Central Limit Theorem and Exponential Distribution

Chapter 4 Continuous Random Variables and Probability Distributions

Section 1.3: A Simple Inventory System

Graduate Econometrics I: What is econometrics?

CPSC 531: System Modeling and Simulation. Carey Williamson Department of Computer Science University of Calgary Fall 2017

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER I EXAMINATION MH4702/MAS446/MTH437 Probabilistic Methods in OR

Random Variables. Definition: A random variable (r.v.) X on the probability space (Ω, F, P) is a mapping

Random variable X is a mapping that maps each outcome s in the sample space to a unique real number x, < x <. ( ) X s. Real Line

Inventory Model (Karlin and Taylor, Sec. 2.3)

CLASS NOTES: BUSINESS CALCULUS

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint

Coffee Hour Problems and Solutions

Transcription:

1 / 26 Hand Simulations Christos Alexopoulos and Dave Goldsman Georgia Institute of Technology, Atlanta, GA, USA 9/2/14

2 / 26 Outline 1 Monte Carlo Integration 2 Making Some π 3 Single-Server Queue 4 (s, S) Inventory System 5 Simulating Random Variables

3 / 26 Monte Carlo Integration Goal: Look at some examples of easy problems that we can simulate by hand (or almost by hand). Monte Carlo Integration First off, let s integrate I = b a g(x)dx = (b a) 1 0 g(a+(b a)u)du, where we get the last equality by substituting u = (x a)/(b a). Of course, we can often do this by analytical methods that we learned back in calculus class, or by numerical methods like the trapezoid rule or something like Gauss-Laguerre integration. But if these methods aren t possible, you can always use MC simulation....

4 / 26 Monte Carlo Integration Suppose U 1,U 2,... are iid Unif(0,1), and define I i (b a)g(a+(b a)u i ) for i = 1,2,...,n. We can use the sample average of the Īn 1 n n i=1 I i as an estimator for I. By the Law of the Unconscious Statistician, notice that E[Īn] = (b a)e[g(a+(b a)u i ] = (b a) g(a+(b a)u)f(u)du (where f(u) is the Unif(0,1) pdf) = (b a) 1 0 g(a+(b a)u)du = I.

Monte Carlo Integration SoĪn is unbiased for I. Since it can also be shown that Var(Īn) = O(1/n), the LLN implies Īn I as n. Example: Suppose I = 1 0 sin(πx)dx (and pretend we don t know the actual answer, 2/π =. 0.6366). Let s take n = 4 Unif(0,1) observations: U 1 = 0.79 U 2 = 0.11 U 3 = 0.68 U 4 = 0.31 Since I i = (b a)g(a+(b a)u i ) = g(u i ) = sin(πu i ), we obtain Ī n = 1 4 4 I i = 1 4 i=1 4 sin(πu i ) = 0.656, i=1 which is close to2/π! (Actually, we got lucky.) 5 / 26

6 / 26 Making Some π Outline 1 Monte Carlo Integration 2 Making Some π 3 Single-Server Queue 4 (s, S) Inventory System 5 Simulating Random Variables

7 / 26 Making Some π Making Some π Consider a unit square (with area one). Inscribe in the square a circle with radius 1/2 (with area π/4). Suppose we toss darts randomly at the square. The probability that a particular dart will land in the inscribed circle is obviously π/4 (the ratio of the two areas). We can use this fact to estimate π. Tossnsuch darts at the square and calculate the proportion ˆp n that land in the circle. Then an estimate for π is ˆπ n = 4ˆp n, which converges toπ as n becomes large by the LLN. For instance, suppose that we throw n = 500 darts at the square and 397 of them land in the circle. Then ˆp n = 0.794, and our estimate for π is ˆπ n = 3.176 not so bad.

Making Some π 8 / 26

9 / 26 Making Some π How would we actually conduct such an experiment? To simulate a dart toss, suppose U 1 and U 2 are iid Unif(0,1). Then (U 1,U 2 ) represents the random position of the dart on the unit square. The dart lands in the circle if ( U 1 1 2 ( + U 2 2) 1 ) 2 1 2 4. Generate n such pairs of uniforms and count up how many of them fall in the circle. Then plug into ˆπ n.

10 / 26 Single-Server Queue Outline 1 Monte Carlo Integration 2 Making Some π 3 Single-Server Queue 4 (s, S) Inventory System 5 Simulating Random Variables

Single-Server Queue Single-Server Queue Customers arrive at a single-server queue with iid interarrival times and iid service times. Customers must wait in a FIFO line if the server is busy. We will estimate the expected customer waiting time, the expected number of people in the system, and the server utilization (proportion of busy time). First, some notation. Customer number = i Interarrival time between customers i 1 and i isi i Customer i s arrival time is A i = i j=1 I j Customer i starts service at timet i = max(a i,d i 1 ) Customer i s waiting time is W Q i = T i A i Customer i s service time iss i Customer i s departure time isd i = T i +S i 11 / 26

Single-Server Queue Example: Suppose we have the following sequence of events... i I i A i T i W Q i S i D i 1 3 3 3 0 7 10 2 1 4 10 6 6 16 3 2 6 16 10 4 20 4 4 10 20 10 6 26 5 5 15 26 11 1 27 6 5 20 27 7 2 29 The average waiting time for the six customers is obviously 6 i=1 WQ i /6 = 7.33. How do we get the average number of people in the system (in line + in service)? 12 / 26

13 / 26 Single-Server Queue Note that arrivals and departures are the only possible times for the number of people in the system, L(t), to change. timet event L(t) 0 simulation begins 0 3 customer 1 arrives 1 4 2 arrives 2 6 3 arrives 3 10 1 departs; 4 arrives 3 15 5 arrives 4 16 2 departs 3 20 3 departs; 6 arrives 3 26 4 departs 2 27 5 departs 1 29 6 departs 0

Single-Server Queue L(t) Queue 5 customer 3 4 4 5 6 2 2 3 3 4 5 6 in 1 1 1 2 2 3 4 5 6 service t 3 4 6 10 15 16 20 26 27 29 The average number in the system is L = 1 29 29 0 L(t)dt = 70 29. 14 / 26

15 / 26 Single-Server Queue Another way to get the average number in the system is to calculate total person-time in system L = 29 6 i=1 = (D i A i ) 29 = 7+12+14+16+12+9 29 = 70 29. Finally, to obtain the estimated server utilization, we easily see (from the picture) that the proportion of time that the server is busy is ˆρ = 26 29.

16 / 26 Single-Server Queue Example: Same events, but last-in-first-out (LIFO) services... i I i A i T i W Q i S i D i 1 3 3 3 0 7 10 2 1 4 23 19 6 29 3 2 6 17 11 4 21 4 4 10 10 0 6 16 5 5 15 16 1 1 17 6 5 20 21 1 2 23 The average waiting time for the six customers is 5.33, and the average number of people in the system turns out to be 58 29 = 2, which in this case turn out to better than FIFO.

17 / 26 (s, S) Inventory System Outline 1 Monte Carlo Integration 2 Making Some π 3 Single-Server Queue 4 (s, S) Inventory System 5 Simulating Random Variables

(s, S) Inventory System (s, S) Inventory System A store sells a product at $d/unit. Our inventory policy is to have at least s units in stock at the start of each day. If the stock slips to less than s by the end of the day, we place an order with our supplier to push the stock back up to S by the beginning of the next day. Let I i denote the inventory at the end of day i, and let Z i denote the order that we place at the end of day i. Clearly, { S I i if I i < s Z i = 0 otherwise. If an order is placed to the supplier at the end of day i, it costs the store K +cz i. It costs $h/unit for the store to hold unsold inventory overnight, and a penalty cost of $p/unit if demand can t be met. No backlogs are allowed. Demand on day i isd i. 18 / 26

19 / 26 (s, S) Inventory System How much money does the store make on day i? Total = Sales Ordering Cost Holding Cost Penalty Cost = d min(d i, inventory at beginning of day i) { K +czi if I i < s 0 otherwise hi i p max(0,d i inventory at beginning of day i) = d min(d i,i i 1 +Z i 1 ) { K +czi if I i < s 0 otherwise hi i p max(0,d i (I i 1 +Z i 1 )).

20 / 26 (s, S) Inventory System Example: Suppose d = 10, s = 3, S = 10, K = 2, c = 4, h = 1, p = 2. Consider the following sequence of demands: D 1 = 5, D 2 = 2, D 3 = 8, D 4 = 6, D 5 = 2, D 6 = 1. Suppose that we start out with an initial stock of I 0 +Z 0 = 10. Day begin sales order hold penalty TOTAL i stock D i I i Z i rev cost cost cost rev 1 10 5 5 0 50 0 5 0 45 2 5 2 3 0 20 0 3 0 17 3 3 8 0 10 30 42 0 10 22 4 10 6 4 0 60 0 4 0 56 5 4 2 2 8 20 34 2 0 16 6 10 1 9 0 10 0 9 0 1

21 / 26 Simulating Random Variables Outline 1 Monte Carlo Integration 2 Making Some π 3 Single-Server Queue 4 (s, S) Inventory System 5 Simulating Random Variables

22 / 26 Simulating Random Variables Simulating Random Variables Example (Discrete Uniform): Consider a D.U. on{1, 2,..., n}, i.e., X = i with probability 1/n for i = 1,2,...,n. (Think of this as an n-sided dice toss for you Dungeons and Dragons fans.) If U Unif(0, 1), we can obtain a D.U. random variate simply by setting X = nu, where is the ceiling (or round up ) function. For example, if n = 10 and we sample a Unif(0,1) random variable U = 0.73, then X = 7.3 = 8.

Simulating Random Variables Example (Another Discrete Random Variable): 0.25 ifx = 2 0.10 ifx = 3 P(X = x) = 0.65 ifx = 4.2 0 otherwise Can t use a die toss to simulate this random variable. Instead, use what s called the inverse transform method. x P(X = x) P(X x) Unif(0,1) s 2 0.25 0.25 [0.00, 0.25] 3 0.10 0.35 (0.25, 0.35] 4.2 0.65 1.00 (0.35, 1.00) Sample U Unif(0, 1). Choose the corresponding x-value, i.e., X = F 1 (U). For example, U = 0.46 means that X = 4.2. 23 / 26

24 / 26 Simulating Random Variables Now we ll use the inverse transform method to generate a continuous random variable. Recall... Theorem: If X is a continuous random variable with cdf F(x), then the random variable F(X) Unif(0, 1). This suggests a way to generate realizations of the RVX. Simply set F(X) = U Unif(0,1) and solve for X = F 1 (U). Old Example: Suppose X Exp(λ). ThenF(x) = 1 e λx for x > 0. Set F(X) = 1 e λx = U. Solve for X, X = 1 λ ln(1 U) Exp(λ).

25 / 26 Simulating Random Variables Example (Generating Uniforms): All of the above RV generation examples relied on our ability to generate a Unif(0,1) RV. For now, let s assume that we can generate numbers that are practically iid Unif(0,1). If you don t like programming, you can use Excel function RAND() or something similar to generate Unif(0,1) s. Here s an algorithm to generate pseudo-random numbers (PRN s), i.e., a series R 1,R 2,... of deterministic numbers that appear to be iid Unif(0,1). Pick a seed integer X 0, and calculate X i = 16807X i 1 mod(2 31 1), i = 1,2,... Then set R i = X i /(2 31 1), i = 1,2,...

26 / 26 Simulating Random Variables Here s an easy FORTRAN implementation of the above algorithm (from Bratley, Fox, and Schrage). FUNCTION UNIF(IX) K1 = IX/127773 (this division truncates, e.g., 5/3 = 1.) IX = 16807*(IX - K1*127773) - K1*2836 (update seed) IF(IX.LT.0)IX = IX + 2147483647 UNIF = IX * 4.656612875E-10 RETURN END In the above function, we input a positive integer IX and the function returns the PRN UNIF, as well as an updated IX that we can use again.