Review
A review of the whole course: the key algorithms and formulas of Chapters 3–7, and the format of the final exam.
The first two chapters are preliminaries (Chapter 1: discrete-event simulation; Chapter 2: probability and statistics). Chapter 1’s hand simulation of a single-server queue (§1.2) comes back on the exam (Part I, question 3).
Chapter 3: Random Number Generation
Linear congruential generators (LCGs):
Necessary and sufficient conditions for a full-period LCG (period , Hull–Dobell theorem). For , the LCG has full period if and only if:
- and are relatively prime (their only common divisor is 1);
- if is a prime that divides , then divides ;
- if 4 divides , then 4 divides .
(For a multiplicative LCG, , the period is at most ; it is reached when is prime and is a primitive element modulo : the PMMLCG.)
Testing RNGs:
- Test for uniformity: chi-square test. Split into subintervals of equal length; = number of the values in interval ;
reject uniformity at level if , the -quantile of . (The serial test applies the same idea to pairs or -tuples of consecutive ’s.)
- Test for independence: runs test (runs up), based on the lengths of the increasing runs in ; the statistic is compared with .
Chapter 4: Generating Random Variates
- Inverse transform method
- Generate .
- Return , where is the c.d.f.
- Discrete (or general) case: return .
- Composition
- (a mixture): randomly select one according to the probabilities .
- Generate a random index with ,
- Return with distribution .
- Convolution: uses the structure of itself, when is a sum of i.i.d. r.v.s (e.g. Erlang = sum of exponentials, binomial = sum of Bernoullis).
- , where the ’s are i.i.d. .
- Generate , independent.
- Return .
- Acceptance–rejection: use a surrogate distribution that is easy to sample from to approximate .
- Majorizing function: for all .
- Normalization: , where .
- Generate .
- Generate , independent of ().
- If , return ; otherwise, go back to step 1 and try again.
- Efficiency: , so the expected number of tries per variate is . A good hugs closely, making close to 1.
- Special techniques
- Box–Muller method (normal)
- Acceptance–rejection polar algorithm (normal)
- Table lookup and the alias method: general techniques for discrete distributions (with finitely many values).
Chapter 5: Input Analysis
Goal: select an input distribution to model an input process (e.g. interarrival times, service times). How to do it? Collect data, then three steps:
- Collect i.i.d. observations of the input random variable of interest (and check independence, §5.1).
- Step I: perform a statistical analysis (summary statistics, histogram, box plot) and hypothesize a distribution family.
- Step II: estimate the parameters of the distribution, e.g. by maximum likelihood (MLE):
- Construct the likelihood function, the joint density (or p.m.f.) of the data as a function of : for i.i.d. data.
- MLE: (the log turns the product into a sum; set the derivative to 0).
- Examples: exponential with mean : ; geometric (failures before the first success): ; : , . An approximate CI for uses the asymptotic normality of the MLE (§5.5).
- Step III: determine the quality of the fit.
- Graphical methods
- Q–Q plot (compares quantiles; sensitive in the tails)
- P–P plot (compares probabilities; sensitive in the middle; also works for discrete data)
- Statistical methods (hypothesis tests of : the data are i.i.d. with distribution )
- Chi-square test: compare the observed counts in intervals with the expected counts :
; reject if . - K–S test: the largest vertical distance between the empirical c.d.f. and :
, , ; reject if the adjusted statistic exceeds the critical value (, or , by case). - Each test has limitations; given a scenario, you should know which test to apply:
- Chi-square test: compare the observed counts in intervals with the expected counts :
- Graphical methods
| chi-square test | K–S test | |
|---|---|---|
| data | discrete or continuous | continuous (the basic form) |
| sample size | large: every (asymptotic test) | any (exact critical values) |
| choices to make | the intervals (the result can depend on them; use equal-probability intervals) | none (no grouping of the data) |
| estimated parameters | degrees of freedom between and | only special cases: all parameters known (), normal (), exponential () |
Chapter 6: Output Analysis
Goal: estimate the system (model) performance from simulation outputs.
Idea: construct i.i.d. replications, since the observations within one run are correlated (and not identically distributed).
Terminating simulation (§6.3)
- Run multiple replications. Observations across runs are i.i.d., so average across runs to construct estimators: = output of run , and the CI is
- Initial conditions: must represent the real system at the start (§6.3.4).
- Control the estimation precision (§6.3.3):
- Absolute half-width : from pilot runs, the smallest with , i.e. roughly .
- From half-width with runs to : , i.e. more runs.
- Relative error : the smallest with , where is the adjusted value that guarantees relative error with respect to the true .
Nonterminating simulation (steady-state parameters, §6.4)
- Initial-data deletion (§6.4.1)
- Delete a number of observations from the beginning of a run (the warm-up period) and use . Trade-off: too small means bias, too large means high variance.
- Use Welch’s procedure to choose : runs, average across runs, smooth with a moving average of window , plot, and eyeball where the curve levels off.
- Then replication/deletion (§6.4.2): runs, each with its first observations deleted; are i.i.d., so use the terminating-simulation CI.
- Batch means method (§6.4.3)
- One run, with very large.
- Split it into batches of size (), with batch means . For large they are approximately i.i.d. normal, so the CI is . Rule of thumb: batches.
- Regenerative method (§6.4.4)
- Identify regeneration points, at which the process probabilistically restarts. Observations over different regeneration cycles are i.i.d.: the pairs = (sum of the observations, number of observations) of cycle .
- , estimated by (biased, but strongly consistent), with CI , .
Multiple performance measures (§6.5)
- , .
- Bonferroni: , for any dependence between the CIs. E.g. for an overall level of at least 90% with measures, make two 95% CIs.
Chapter 7: Variance Reduction Techniques
Goal: a smaller for the same number of runs, i.e. a narrower CI at no additional simulation cost.
- Common random numbers (§7.1): to compare systems, ,
; use the same random numbers for both systems to make .- Use the inverse transform (monotone, one per variate).
- Synchronization: the same must be used for the same purpose in both systems (dedicated streams, or generate the variates beforehand).
- Requires both outputs to react to the ’s in the same direction; otherwise it backfires.
- Antithetic variates (§7.2): for one system,
- use the ’s in one replication and the ’s in the other;
- average the pair: , which is better than when (output monotone in the ’s).
- Do not combine with CRN.
- Control variates (§7.3)
- ; can be observed in the same run; is known; and are correlated.
- (minus sign), unbiased for every ; best , giving .
- In practice is estimated from the runs, which makes the estimator slightly biased.
- Indirect estimation (§7.4): use known relationships and replace random quantities by known deterministic quantities, e.g. instead of ; with Little’s law (, ), also and .
- Stratified sampling (§7.5): strata with known probabilities :
; estimate each by sampling within stratum , and combine with the known weights . - Conditioning (§7.6): , where can be obtained analytically; use instead of . Its variance is (law of total variance).
- Importance sampling (§7.7): use a change of measure, so that the desired quantity under the new distribution has a smaller variance:
; sample and use . Choose roughly proportional to (e.g. shifted toward the rare event).
Exam format
Bring your book (for the tables: , , , K–S critical values) and your calculator.
Part I (3 questions)
- Random variate generation (Chapter 4): e.g. derive an inverse-transform, composition, convolution or acceptance–rejection algorithm for a given distribution, and compute its efficiency.
- Input analysis (Chapter 5): MLE (write , take the log, differentiate, solve).
- Queueing simulation (Chapter 1, §1.2). Given a table of interarrival times and service times :
- draw the sample path ( or , and the server status);
- calculate performance measures, e.g. the average delay , the time-average number in queue , and the server utilization , where if the server is busy at time and 0 if idle;
- fit a distribution to the data (e.g. an exponential, by MLE) and perform a hypothesis test (chi-square or K–S).
Recipe for the hand simulation: arrival times ; start of service ; delay ; departure . Then list the event times in order, read off and between events, and add up the areas (time length × level).
Part II (3 questions)
- Output analysis (Chapter 6): construct a CI, and estimate the number of runs needed to achieve a given precision (absolute , or relative ).
- Two questions on variance reduction (Chapter 7). For a given performance, measure:
- the variance of the crude Monte Carlo estimator (plain sampling, no variance reduction);
- the variance of the estimator with the variance reduction technique, and the percentage reduction compared with 1.
| example | performance | 1. crude variance | 2. variance with the technique | reduction |
|---|---|---|---|---|
| §7.2 | , two evaluations | antithetic: | 96.8% | |
| §7.3 | , one evaluation | control variate : | 98.4% | |
| §7.5 | , evaluations | stratified (two halves): | 73% | |
| §7.7 | , | importance sampling, : | factor |