Where real stuff starts

Slides:



Advertisements
Similar presentations
Random Processes Introduction (2)
Advertisements

Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
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.
Statistics review of basic probability and statistics.
 1  Outline  Model  problem statement  detailed ARENA model  model technique  Output Analysis.
Discrete Time Markov Chains
Lecture 13 – Continuous-Time Markov Chains
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 Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
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.
Chapter 21 Random Variables Discrete: Bernoulli, Binomial, Geometric, Poisson Continuous: Uniform, Exponential, Gamma, Normal Expectation & Variance, Joint.
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.
ETM 607 – Random Number and Random Variates
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
 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.
© 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
0 K. Salah 2. Review of Probability and Statistics Refs: Law & Kelton, Chapter 4.
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.
Simulation Tutorial By Bing Wang Assistant professor, CSE Department, University of Connecticut Web site.
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,
Palm Calculus Made Easy The Importance of the Viewpoint JY Le Boudec 1.
Network Simulation Motivation: r learn fundamentals of evaluating network performance via simulation Overview: r fundamentals of discrete event simulation.
1 OUTPUT ANALYSIS FOR SIMULATIONS. 2 Introduction Analysis of One System Terminating vs. Steady-State Simulations Analysis of Terminating Simulations.
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
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.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Stochastic Process - Introduction
Auburn University
Computer Simulation Henry C. Co Technology and Operations Management,
OPERATING SYSTEMS CS 3502 Fall 2017
Linear Algebra Review.
Prepared by Lloyd R. Jaisingh
Basic simulation methodology
ETM 607 – Spreadsheet Simulations
Outline Introduction Signal, random variable, random process and spectra Analog modulation Analog to digital conversion Digital transmission through baseband.
Basic MC/Defn/Short Answer/Application Cumulative
Algorithm Analysis CSE 2011 Winter September 2018.
Chapter 10 Verification and Validation of Simulation Models
Turnstile Streaming Algorithms Might as Well Be Linear Sketches
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
Properties of Random Numbers
Lecture 2 – Monte Carlo method in finance
COMP60621 Designing for Parallelism
STOCHASTIC HYDROLOGY Random Processes
Validating a Random Number Generator
September 1, 2010 Dr. Itamar Arel College of Engineering
Dept. of Electrical & Computer engineering
Chapter 6 Random Processes
Ns-3 Training Simulator core ns-3 training, June 2016.
CS723 - Probability and Stochastic Processes
Lecture 11 – Stochastic Processes
Presentation transcript:

Where real stuff starts 28/05/2019 Simulation Where real stuff starts

ToC What, transience, stationarity How, discrete event, recurrence 28/05/2019 What, transience, stationarity How, discrete event, recurrence Accuracy of output Monte Carlo Random Number Generators How to sample 1

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

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

Information server, scenario 1 28/05/2019 Information server, scenario 1 4

Information server, scenario 2 28/05/2019 Information server, scenario 2 5

Stationarity In scenario 1: In scenario 2: 28/05/2019 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 28/05/2019 A property of a stochastic model Xt Let Xt be a stochastic model that represents the state of the simulator at time t. It is stationary iff for any s>0 (Xt1, Xt2, …, Xtk) has same distribution as (Xt1+s, Xt2+s, …, Xtk+s) i.e. simulation does not get “old” 7

Classical Cases Markov models 28/05/2019 Markov models State Xt 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 28/05/2019 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) 28/05/2019 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

Quiz 28/05/2019 12

2 Simulation Techniques 28/05/2019 Discrete event simulations Recurrences Stochastic recurrences 13

Discrete event simulation Uses an Event Scheduler 28/05/2019 t1 t2 t3 queue length 1 2 t4 Example: Information system modelled as a single server queue Three event classes arrival service Departure One event scheduler (global system clock) arrival service departure 14

Scheduler: Timeline t1 t2 t3 queue length 1 2 t4 initialization Step 1 t1 t2 t3 queue length 1 2 t4 Scheduler: Timeline 28/05/2019 initialization Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 service t=0 arrival t=t1 arrival t=t1 departure t=t2 service t=0 departure t=t2 arrival t=t4 t=t1 departure t=t2 service arrival t=t4 service t=t2 departure t=t3 arrival t=t4 departure t=t3 arrival t=t4 Event being executed arrival t=0 State of scheduler 15

Statistical Counters 28/05/2019 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 16

A Classical Organization of Simulation Code 28/05/2019 Events contain specific code A main loop advances the state of the scheduler Example: in the code of a departure event 17

28/05/2019 Main program 18

28/05/2019 19

Stochastic Recurrence 28/05/2019 An alternative to discrete event simulation faster but requires more work on the model not always applicable Defined by iteration: 20

Example: random waypoint mobility model 28/05/2019 21

28/05/2019 22

28/05/2019 23

24

Queuing System implemented as Stochastic Recurrence 28/05/2019 25

28/05/2019 26

3 Accuracy of Simulation Output 28/05/2019 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 27

Results of 30 Independent Replications 28/05/2019 28

28/05/2019 Do They Look Normal ? 29

28/05/2019 Bootstrap Replicates 30

Confidence Intervals Mean, bootstrap Median Mean, normal approx 31 28/05/2019 Mean, bootstrap Median Mean, normal approx 31

5 Random Number Generator 28/05/2019 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) 32

The Linear Congruential Generator of ns2 28/05/2019 uniform qq plot autocorrelation 33

Lag Diagram, 1000 points 28/05/2019 34

Period of RNG RNG is in fact periodic 28/05/2019 RNG is in fact periodic Period should be much larger than maximum number of uses 35

Two Parallel Streams with too simple a RNG 28/05/2019 36

28/05/2019 Impact of RNG 37

Take Home Message 28/05/2019 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 38

6 Sampling From A Distribution 28/05/2019 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 39

CDF Inversion 28/05/2019 Applies to real or integer valued RV 40

28/05/2019 41

Example: integer valued RV 28/05/2019 42

28/05/2019 43

28/05/2019 44

Rejection Sampling 28/05/2019 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 ? 1000 samples 45

Rejection Sampling for Conditional Distribution 28/05/2019 This is the main idea How can you apply this to the example in the previous slide ? 46

Rejection Sampling for General Distributions 28/05/2019 47

28/05/2019 48

A Sample from a Weird Distribution 28/05/2019 49

28/05/2019 50

Another Sample from a Weird Distribution 28/05/2019 51

6.3 Ad-Hoc Methods 28/05/2019 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) 52

A Sample from a 2d- Normal Vector 28/05/2019 53

4 Monte Carlo Simulation 28/05/2019 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 54

28/05/2019 55

28/05/2019 56

28/05/2019 57

28/05/2019 58

Take Home Message 28/05/2019 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) 59

Questions 28/05/2019 60

Questions Q4.2 A node receives messages from 2 sensors S1 and S2. Each of the sources sends messages independently of each other. The sequence of time intervals between messages sent by source S1 is iid, with a Gaussian distribution with mean m1 and variance s12 and similarly for S2. The node works as follows. It waits for the next message from S1. When it has received one message from S1, it waits for the next message from S2, and sends a message of its own. How do you implement a simulator for this system ? Q4.1 A system contains a population of tasks that arrive as a Poisson process. Each task spends a time that is random, iid, independent of the arrival process, and with Pareto distribution. How do you implement a simulation of this system ? 61

Conclusion Simulating well requires knowing the concepts of Transience 28/05/2019 Simulating well requires knowing the concepts of Transience Confidence intervals Sampling methods 62