Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.

Slides:



Advertisements
Similar presentations
+ Validation of Simulation Model. Important but neglected The question is How accurately does a simulation model (or, for that matter, any kind of model)
Advertisements

Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
SE503 Advanced Project Management Dr. Ahmed Sameh, Ph.D. Professor, CS & IS Project Uncertainty Management.
Lab Assignment 1 COP 4600: Operating Systems Principles Dr. Sumi Helal Professor Computer & Information Science & Engineering Department University of.
Random number generation Algorithms and Transforms to Univariate Distributions.
 1  Outline  Model  problem statement  detailed ARENA model  model technique  Output Analysis.
Lecture 13 – Continuous-Time Markov Chains
Simulation. Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires.
1 Perfect Simulation and Stationarity of a Class of Mobility Models Jean-Yves Le Boudec (EPFL) Milan Vojnovic (Microsoft Research Cambridge)
Queuing Theory For Dummies
1 Summarizing Performance Data Confidence Intervals Important Easy to Difficult Warning: some mathematical content.
Simulation.
Previously Optimization Probability Review Inventory Models Markov Decision Processes Queues.
Discrete Event Simulation
Monté Carlo Simulation MGS 3100 – Chapter 9. Simulation Defined A computer-based model used to run experiments on a real system.  Typically done on a.
Lecture 11 – Stochastic Processes
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
1 Summarizing Performance Data Confidence Intervals Important Easy to Difficult Warning: some mathematical content.
ETM 607 – Random Number and Random Variates
Introduction to Monte Carlo Methods D.J.C. Mackay.
References for M/G/1 Input Process
Analysis of Simulation Results Andy Wang CIS Computer Systems Performance Analysis.
1 CE 530 Molecular Simulation Lecture 7 David A. Kofke Department of Chemical Engineering SUNY Buffalo
Simulation Output Analysis
Simulation II IE 2030 Lecture 18. Outline: Simulation II Advanced simulation demo Review of concepts from Simulation I How to perform a simulation –concepts:
 1  Outline  stages and topics in simulation  generation of random variates.
The University of Texas at Arlington Topics in Random Processes CSE 5301 – Data Modeling Guest Lecture: Dr. Gergely Záruba.
Monte Carlo Simulation CWR 6536 Stochastic Subsurface Hydrology.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.
© 2003, Carla Ellis Simulation Techniques Overview Simulation environments emulation exec- driven sim trace- driven sim stochastic sim Workload parameters.
CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT Class Location:
Chapter 7 Random-Number Generation
Module 1: Statistical Issues in Micro simulation Paul Sousa.
0 K. Salah 2. Review of Probability and Statistics Refs: Law & Kelton, Chapter 4.
Simulated Annealing.
Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.
Suppressing Random Walks in Markov Chain Monte Carlo Using Ordered Overrelaxation Radford M. Neal 발표자 : 장 정 호.
Simulation techniques Summary of the methods we used so far Other methods –Rejection sampling –Importance sampling Very good slides from Dr. Joo-Ho Choi.
Lecture 4: Statistics Review II Date: 9/5/02  Hypothesis tests: power  Estimation: likelihood, moment estimation, least square  Statistical properties.
Chapter 10 Verification and Validation of Simulation Models
ECE 466/658: Performance Evaluation and Simulation Introduction Instructor: Christos Panayiotou.
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
Simulation & Confidence Intervals COMP5416 Advanced Network Technologies.
Validating a Random Number Generator Based on: A Test of Randomness Based on the Consecutive Distance Between Random Number Pairs By: Matthew J. Duggan,
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 25 Simulation.
1 OUTPUT ANALYSIS FOR SIMULATIONS. 2 Introduction Analysis of One System Terminating vs. Steady-State Simulations Analysis of Terminating Simulations.
1 Summarizing Performance Data Confidence Intervals Important Easy to Difficult Warning: some mathematical content.
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
1 EE571 PART 3 Random Processes Huseyin Bilgekul Eeng571 Probability and astochastic Processes Department of Electrical and Electronic Engineering Eastern.
Dr. Anis Koubâa CS433 Modeling and Simulation
ETM 607 – Putting It All Together Review for MidTerm II Apply Lessons Learned in a Team Lab - Input Modeling - Absolute Output Analysis - Relative Output.
Previously Definition of a stationary process (A) Constant mean (B) Constant variance (C) Constant covariance White Noise Process:Example of Stationary.
ECE-7000: Nonlinear Dynamical Systems 2. Linear tools and general considerations 2.1 Stationarity and sampling - In principle, the more a scientific measurement.
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
Kevin Stevenson AST 4762/5765. What is MCMC?  Random sampling algorithm  Estimates model parameters and their uncertainty  Only samples regions of.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
MONTE CARLO METHOD DISCRETE SIMULATION RANDOM NUMBER GENERATION Chapter 3 : Random Number Generation.
OPERATING SYSTEMS CS 3502 Fall 2017
Prepared by Lloyd R. Jaisingh
ETM 607 – Spreadsheet Simulations
Basic MC/Defn/Short Answer/Application Cumulative
Chapter 10 Verification and Validation of Simulation Models
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
STOCHASTIC HYDROLOGY Random Processes
Validating a Random Number Generator
Dept. of Electrical & Computer engineering
Where real stuff starts
Lecture 11 – Stochastic Processes
Presentation transcript:

Simulation Where real stuff starts

ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random Number Generators 6.How to sample 1

1 What is a simulation ? An experiment in computer Important differences Simulated vs real time Serialization of events 2

Stationarity A simulation can be terminating or not For a terminating simulation you should make sure it is stationary 3

Information server, scenario 1 4

Information server, scenario 2 5

Stationarity In scenario 1: Transient phase, followed by “typical” (=stationary) phase You want to measure things only in the stationary phase Otherwise: non reproduceable, non typical In scenario 2: There is no stationary regime “walk to infinity” you should not do a non terminating simulation with this scenario 6

Definition of Stationarity A property of a stochastic model X t Let X t be a stochastic model that represents the state of the simulator at time t. It is stationary iff for any s>0 (X t1, X t2, …, X tk ) has same distribution as (X t1+s, X t2+s, …, X tk+s ) i.e. simulation does not get “old” 7

Classical Cases Markov models State X t is sufficient to draw the future of the simulation Common case for all simulations For a Markov model, over a discrete state space If you run the simulation long enough it will either walk to infinity (unstable) or converge to stationary Ex: queue with  >1: unstable queue with  <1: becomes stationary after transient If the state space is strongly connected (any state can be reached from any state) then there is 0 or 1 stationary regime Ex: queue Else, there may be several distinct stationary regimes Ex: system with failure modes 8

Stationarity and Transience Knowing whether a model is stationary is sometimes a hard problem We will see important models where this is solved Ex: Solved for single queues, not for networks Ex: time series models Reasoning about your system may give you indications Do you expect growth ? Do you expect seasonality ? Once you believe your model is stationary, you should handle transients Remove (how ? Look at your output and guess) Sometimes it is possible to avoid transients at all (perfect simulation) 9

Non-Stationary (Time Dependent Inputs) 10

Typical Reasons For Non Stationarity Obvious dependency on time Seasonality, growth Can be ignored at small time scale (minute) Non Stability: Explosion Queue with utilization factor >1 Non Stability: Freezing Simulation System becomes slower with time (aging) Typically because there are rare events of large impact (« Kings ») The longer the simulation, the larger the largest king Ex: time between regeneration points has infinite mean We’ll come back to this in the chapter « Importance of the View Point » 11

2 Simulation Techniques Discrete event simulations Recurrences Stochastic recurrences 12

Discrete event simulation Uses an Event Scheduler Example: Information system modelled as a single server queue Three event classes arrival service Departure One event scheduler (global system clock) 13 0 t1t1 t2t2 t3t3 queue length 1 2 t4t4 arrivalservice departure

Scheduler: Timeline 14 departure t=t 2 service t=t 2 arrival t=t 4 service t=t 2 departure t=t 3 arrival t=t 4 departure t=t 3 arrival t=t 4 service t=0 arrival t=t 1 arrival t=0 arrival t=t 1 departure t=t 2 service t=0 departure t=t 2 arrival t=t 4 arrival t=t 1 arrival t=0 initialization 0 t1t1 t2t2 t3t3 queue length 1 2 t4t4 State of scheduler Event being executed Step 1Step 2Step 3Step 4Step 5Step 6

Statistical Counters Assume we want to output: mean queue length and mean response time. How do we do this ? Note the difference between Event based statistic Time based statistic 15

A Classical Organization of Simulation Code Events contain specific code A main loop advances the state of the scheduler Example: in the code of a departure event 16

Main program 17

Stochastic Recurrence An alternative to discrete event simulation faster but requires more work on the model not always applicable Defined by iteration: 18

Example: random waypoint mobility model 19

20

21

Queuing System implemented as Stochastic Recurrence 22

23

3 Accuracy of Simulation Output A stochastic simulation produces a random output, we need confidence intervals Method of choice: independent replications Remove transients For non terminating simulations Be careful to have truly random seeds Ex: use computer time as seed 24

Results of 30 Independent Replications 25

Do They Look Normal ? 26

Bootstrap Replicates 27

Confidence Intervals 28 Mean, normal approx Median Mean, bootstrap

5 Random Number Generator A stochastic simulation does not use truly random numbers but pseudo- random numbers Produces a random number » U(0,1) Example (obsolete but commonly used, eg in ns2: ) Output appears to be random (see next slides) 29

The Linear Congruential Generator of ns2 30 uniform qq plot autocorrelation

Lag Diagram, 1000 points 31

Period of RNG RNG is in fact periodic Period should be much larger than maximum number of uses 32

Two Parallel Streams with too simple a RNG 33

Impact of RNG 34

Take Home Message Be careful to have a RNG that has a period orders of magnitude larger than what you will ever use in the simulation Serialize the use of the RNG rather than parallel streams 35

6 Sampling From A Distribution Pb is: Given a distribution F(), and a RNG, produce some sample X that is drawn from this distribution A common task in simulation Matlab does it for us most of the time, but not always Two generic methods CDF inversion Rejection sampling 36

CDF Inversion Applies to real or integer valued RV 37

38

Example: integer valued RV 39

40

Rejection Sampling Applies more generally, also to joint n-dimensional distributions Example 1: conditional distribution on this area Step1 : Can you sample a point uniformly in the bounding rectangle ? Step 2: How can you go from there to a uniform sample inside the non convex area ? samples

Rejection Sampling for Conditional Distribution This is the main idea How can you apply this to the example in the previous slide ? 42

Rejection Sampling for General Distributions 43

44

A Sample from a Weird Distribution 45

46

Another Sample from a Weird Distribution 47

6.3 Ad-Hoc Methods Optimized methods exist for some common distributions Optimization = reduce computing time If implemented in your tool, use them ! Example: simulating a normal distribution Inversion method is not simple (no closed form for F -1 ) Rejection method is possible But a more efficient method exists, for drawing jointly 2 independent normal RV There are also ad-hoc methods for n-dimensional normal distributions (gaussian vectors) 48

A Sample from a 2d- Normal Vector 49

4 Monte Carlo Simulation A simple method to compute integrals of all kinds Idea: interpret the integral as Assume you can simulate as many independent samples of X as you want 50

51

52

53

54

Take Home Message Most hard problems relative to computing a probability or an integral can be solved with Monte Carlo Braindumb but why not Run time may be large -> importance sampling techniques (see later in this lecture) 55

Conclusion Simulating well requires knowing the concepts of Transience Confidence intervals Sampling methods 56