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):

zi=(azi−1+c) mod m,ui=zim.z_i = (a z_{i-1} + c) \bmod m, \qquad u_i = \frac{z_i}{m} .

Necessary and sufficient conditions for a full-period LCG (period mm, Hull–Dobell theorem). For c≠0c \ne 0, the LCG has full period if and only if:

  1. cc and mm are relatively prime (their only common divisor is 1);
  2. if qq is a prime that divides mm, then qq divides a−1a - 1;
  3. if 4 divides mm, then 4 divides a−1a - 1.

(For a multiplicative LCG, c=0c = 0, the period is at most m−1m - 1; it is reached when mm is prime and aa is a primitive element modulo mm: the PMMLCG.)

Testing RNGs:

  1. Test for uniformity: chi-square test. Split [0,1][0, 1] into kk subintervals of equal length; fjf_j = number of the nn values uiu_i in interval jj;

    χ2=kn∑j=1k(fj−nk)2;\chi^2 = \frac{k}{n}\sum_{j=1}^k \Big(f_j - \frac{n}{k}\Big)^2 ;

    reject uniformity at level α\alpha if χ2>χk−1, 1−α2\chi^2 > \chi^2_{k-1,\,1-\alpha}, the (1−α)(1-\alpha)-quantile of χk−12\chi^2_{k-1}. (The serial test applies the same idea to pairs or dd-tuples of consecutive uiu_i’s.)
  2. Test for independence: runs test (runs up), based on the lengths of the increasing runs in u1,u2,…u_1, u_2, \dots; the statistic is compared with χ62\chi^2_6.

Chapter 4: Generating Random Variates

  • Inverse transform method
    1. Generate U∼U(0,1)U \sim U(0, 1).
    2. Return X=F−1(U)X = F^{-1}(U), where FF is the c.d.f.
    • Discrete (or general) case: return X=min⁡{x:F(x)≥U}X = \min\{x : F(x) \ge U\}.
  • Composition
    • F(x)=∑j=1∞pjFj(x)F(x) = \sum_{j=1}^\infty p_j F_j(x) (a mixture): randomly select one FjF_j according to the probabilities pjp_j.
    1. Generate a random index JJ with P(J=j)=pjP(J = j) = p_j, j=1,2,…j = 1, 2, \dots
    2. Return XX with distribution FJF_J.
  • Convolution: uses the structure of XX itself, when XX is a sum of i.i.d. r.v.s (e.g. Erlang = sum of exponentials, binomial = sum of Bernoullis).
    • X=Y1+Y2+⋯+YmX = Y_1 + Y_2 + \cdots + Y_m, where the YiY_i’s are i.i.d. ∼G\sim G.
    1. Generate Y1,Y2,…,Ym∼GY_1, Y_2, \dots, Y_m \sim G, independent.
    2. Return X=Y1+Y2+⋯+YmX = Y_1 + Y_2 + \cdots + Y_m.
  • Acceptance–rejection: use a surrogate distribution that is easy to sample from to approximate ff.
    • Majorizing function: t(x)≥f(x)t(x) \ge f(x) for all xx.
    • Normalization: r(x)=t(x)∫−∞∞t(x) dx=t(x)Cr(x) = \dfrac{t(x)}{\int_{-\infty}^{\infty} t(x)\, dx} = \dfrac{t(x)}{C}, where C=∫t(x) dx≥1C = \int t(x)\, dx \ge 1.
    1. Generate Y∼rY \sim r.
    2. Generate U∼U(0,1)U \sim U(0, 1), independent of YY (U⊥YU \perp Y).
    3. If U≤f(Y)/t(Y)U \le f(Y)/t(Y), return X=YX = Y; otherwise, go back to step 1 and try again.
    • Efficiency: P(accept)=1/CP(\text{accept}) = 1/C, so the expected number of tries per variate is CC. A good tt hugs ff closely, making CC 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:

  1. Collect i.i.d. observations of the input random variable of interest (and check independence, §5.1).
  2. Step I: perform a statistical analysis (summary statistics, histogram, box plot) and hypothesize a distribution family.
  3. Step II: estimate the parameters of the distribution, e.g. by maximum likelihood (MLE):
    1. Construct the likelihood function, the joint density (or p.m.f.) of the data as a function of θ\theta: L(θ)=fθ(x1,x2,…,xn)=∏i=1nfθ(xi)L(\theta) = f_\theta(x_1, x_2, \dots, x_n) = \prod_{i=1}^n f_\theta(x_i) for i.i.d. data.
    2. MLE: θ^=arg⁡max⁡θL(θ)=arg⁡max⁡θln⁡L(θ)\hat\theta = \arg\max_\theta L(\theta) = \arg\max_\theta \ln L(\theta) (the log turns the product into a sum; set the derivative to 0).
    3. Examples: exponential with mean θ\theta: θ^=xˉ\hat\theta = \bar x; geometric (failures before the first success): θ^=1/(1+xˉ)\hat\theta = 1/(1 + \bar x); U(a,b)U(a, b): a^=min⁡xi\hat a = \min x_i, b^=max⁡xi\hat b = \max x_i. An approximate CI for θ\theta uses the asymptotic normality of the MLE (§5.5).
  4. Step III: determine the quality of the fit.
    1. Graphical methods
      1. Q–Q plot (compares quantiles; sensitive in the tails)
      2. P–P plot (compares probabilities; sensitive in the middle; also works for discrete data)
    2. Statistical methods (hypothesis tests of H0H_0: the data are i.i.d. with distribution F^\hat F)
      1. Chi-square test: compare the observed counts NjN_j in kk intervals with the expected counts npjnp_j:
        χ2=∑j=1k(Nj−npj)2npj\chi^2 = \sum_{j=1}^k \frac{(N_j - np_j)^2}{np_j}; reject if χ2>χk−1, 1−α2\chi^2 > \chi^2_{k-1,\,1-\alpha}.
      2. K–S test: the largest vertical distance between the empirical c.d.f. and F^\hat F:
        Dn=max⁡{Dn+,Dn−}D_n = \max\{D_n^+, D_n^-\}, Dn+=max⁡i{in−F^(x(i))}D_n^+ = \max_i\{\frac{i}{n} - \hat F(x_{(i)})\}, Dn−=max⁡i{F^(x(i))−i−1n}D_n^- = \max_i\{\hat F(x_{(i)}) - \frac{i-1}{n}\}; reject if the adjusted statistic exceeds the critical value (cc, c′c' or c′′c'', by case).
      3. Each test has limitations; given a scenario, you should know which test to apply:
chi-square test K–S test
data discrete or continuous continuous (the basic form)
sample size large: every npj≥5np_j \ge 5 (asymptotic test) any nn (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 k−m−1k - m - 1 and k−1k - 1 only special cases: all parameters known (cc), normal (c′c'), exponential (c′′c'')

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: XjX_j = output of run jj, and the CI is

    Xˉ(n)±tα/2, n−1S2(n)n.\bar X(n) \pm t_{\alpha/2,\,n-1}\sqrt{\frac{S^2(n)}{n}} .

    • Initial conditions: must represent the real system at the start (§6.3.4).
    • Control the estimation precision (§6.3.3):
      • Absolute half-width β\beta: from n0n_0 pilot runs, the smallest nn with tα/2, n−1S2(n0)/n≤βt_{\alpha/2,\,n-1}\sqrt{S^2(n_0)/n} \le \beta, i.e. roughly n≈S2(n0) tα/2, n−12/β2n \approx S^2(n_0)\, t^2_{\alpha/2,\,n-1}/\beta^2.
      • From half-width β1\beta_1 with n1n_1 runs to β2\beta_2: n2≈n1(β1/β2)2n_2 \approx n_1(\beta_1/\beta_2)^2, i.e. n2−n1n_2 - n_1 more runs.
      • Relative error γ\gamma: the smallest nn with tα/2, n−1S2(n)/n / ∣Xˉ(n)∣≤γ′t_{\alpha/2,\,n-1}\sqrt{S^2(n)/n}\,/\,|\bar X(n)| \le \gamma', where γ′=γ/(1+γ)\gamma' = \gamma/(1 + \gamma) is the adjusted value that guarantees relative error γ\gamma with respect to the true μ\mu.

Nonterminating simulation (steady-state parameters, §6.4)

  • Initial-data deletion (§6.4.1)
    • Delete a number ll of observations from the beginning of a run (the warm-up period) and use Yˉ(m,l)=1m−l∑i=l+1mYi\bar Y(m, l) = \frac{1}{m - l}\sum_{i=l+1}^m Y_i. Trade-off: ll too small means bias, ll too large means high variance.
    • Use Welch’s procedure to choose ll: nn runs, average across runs, smooth with a moving average of window ww, plot, and eyeball where the curve levels off.
    • Then replication/deletion (§6.4.2): nn runs, each with its first ll observations deleted; Xj=Yˉj(m′,l)X_j = \bar Y_j(m', l) are i.i.d., so use the terminating-simulation CI.
  • Batch means method (§6.4.3)
    • One run, Y1,Y2,…,YmY_1, Y_2, \dots, Y_m with mm very large.
    • Split it into nn batches of size kk (m=nkm = nk), with batch means Yˉ1(k),…,Yˉn(k)\bar Y_1(k), \dots, \bar Y_n(k). For large kk they are approximately i.i.d. normal, so the CI is Yˉ(n,k)±tα/2, n−1SYˉ2/n\bar Y(n, k) \pm t_{\alpha/2,\,n-1}\sqrt{S^2_{\bar Y}/n}. Rule of thumb: 10≤n≤3010 \le n \le 30 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 (Zj,Nj)(Z_j, N_j) = (sum of the observations, number of observations) of cycle jj.
    • μ=E[Z]/E[N]\mu = \mathbf{E}[Z]/\mathbf{E}[N], estimated by μ^=Zˉ/Nˉ\hat\mu = \bar Z/\bar N (biased, but strongly consistent), with CI μ^±zα/2σ^V2/n′ / Nˉ\hat\mu \pm z_{\alpha/2}\sqrt{\hat\sigma_V^2/n'}\,/\,\bar N, σ^V2=σ^11−2μ^σ^12+μ^2σ^22\hat\sigma_V^2 = \hat\sigma_{11} - 2\hat\mu\hat\sigma_{12} + \hat\mu^2\hat\sigma_{22}.

Multiple performance measures (§6.5)

  • P(Vi∈Ii)=1−αiP(V_i \in I_i) = 1 - \alpha_i, i=1,…,ri = 1, \dots, r.
  • Bonferroni: P(Vi∈Ii ∀i)≥1−∑i=1rαiP(V_i \in I_i\ \forall i) \ge 1 - \sum_{i=1}^r \alpha_i, for any dependence between the CIs. E.g. for an overall level of at least 90% with r=2r = 2 measures, make two 95% CIs.

Chapter 7: Variance Reduction Techniques

Goal: a smaller Var⁡\operatorname{Var} for the same number of runs, i.e. a narrower CI at no additional simulation cost.

  • Common random numbers (§7.1): to compare systems, Z=X1−X2Z = X_1 - X_2,
    Var⁡(Z)=Var⁡(X1)+Var⁡(X2)−2cov⁡(X1,X2)\operatorname{Var}(Z) = \operatorname{Var}(X_1) + \operatorname{Var}(X_2) - 2\operatorname{cov}(X_1, X_2); use the same random numbers for both systems to make cov⁡>0\operatorname{cov} > 0.
    • Use the inverse transform (monotone, one uu per variate).
    • Synchronization: the same uu must be used for the same purpose in both systems (dedicated streams, or generate the variates beforehand).
    • Requires both outputs to react to the uu’s in the same direction; otherwise it backfires.
  • Antithetic variates (§7.2): for one system,
    • use the uiu_i’s in one replication and the 1−ui1 - u_i’s in the other;
    • average the pair: Var⁡(X(1)+X(2)2)=σ2+cov⁡(X(1),X(2))2\operatorname{Var}\Big(\frac{X^{(1)} + X^{(2)}}{2}\Big) = \frac{\sigma^2 + \operatorname{cov}(X^{(1)}, X^{(2)})}{2}, which is better than σ2/2\sigma^2/2 when cov⁡<0\operatorname{cov} < 0 (output monotone in the uu’s).
    • Do not combine with CRN.
  • Control variates (§7.3)
    • μ=E[X]\mu = \mathbf{E}[X]; YY can be observed in the same run; ν=E[Y]\nu = \mathbf{E}[Y] is known; XX and YY are correlated.
    • Xc=X−a(Y−ν)X_c = X - a(Y - \nu) (minus sign), unbiased for every aa; best a∗=cov⁡(X,Y)/Var⁡(Y)a^* = \operatorname{cov}(X, Y)/\operatorname{Var}(Y), giving Var⁡(Xc∗)=(1−ρXY2)Var⁡(X)\operatorname{Var}(X_c^*) = (1 - \rho_{XY}^2)\operatorname{Var}(X).
    • In practice a∗a^* 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. w~(n)=d^(n)+E[S]\tilde w(n) = \hat d(n) + \mathbf{E}[S] instead of w^(n)\hat w(n); with Little’s law (L=λwL = \lambda w, LQ=λdL_Q = \lambda d), also L~=λw~\tilde L = \lambda\tilde w and Q~=λd^\tilde Q = \lambda\hat d.
  • Stratified sampling (§7.5): strata Y=1∣Y=2∣⋯Y = 1 \mid Y = 2 \mid \cdots with known probabilities P(Y=i)P(Y = i):
    μ=∑iE[X∣Y=i] P(Y=i)\mu = \sum_i \mathbf{E}[X \mid Y = i]\,P(Y = i); estimate each E[X∣Y=i]\mathbf{E}[X \mid Y = i] by sampling within stratum ii, and combine with the known weights P(Y=i)P(Y = i).
  • Conditioning (§7.6): μ=E[X]=E[E[X∣Z]]\mu = \mathbf{E}[X] = \mathbf{E}\big[\mathbf{E}[X \mid Z]\big], where E[X∣Z=z]\mathbf{E}[X \mid Z = z] can be obtained analytically; use E[X∣Z]\mathbf{E}[X \mid Z] instead of XX. Its variance is Var⁡(X)−E[Var⁡(X∣Z)]≤Var⁡(X)\operatorname{Var}(X) - \mathbf{E}[\operatorname{Var}(X \mid Z)] \le \operatorname{Var}(X) (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:
    μ=Ef[h(Y)]=Eg[h(Y) f(Y)/g(Y)]\mu = \mathbf{E}_f[h(Y)] = \mathbf{E}_g\big[h(Y)\,f(Y)/g(Y)\big]; sample Yi∼gY_i \sim g and use μ^=1n∑ih(Yi) f(Yi)/g(Yi)\hat\mu = \frac{1}{n}\sum_i h(Y_i)\,f(Y_i)/g(Y_i). Choose gg roughly proportional to hfh f (e.g. shifted toward the rare event).

Exam format

Bring your book (for the tables: zz, tt, χ2\chi^2, K–S critical values) and your calculator.

Part I (3 questions)

  1. 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.
  2. Input analysis (Chapter 5): MLE (write L(θ)L(\theta), take the log, differentiate, solve).
  3. Queueing simulation (Chapter 1, §1.2). Given a table of interarrival times AiA_i and service times SiS_i:
    • draw the sample path (N(t)N(t) or Q(t)Q(t), and the server status);
    • calculate performance measures, e.g. the average delay d^(n)=1n∑Di\hat d(n) = \frac{1}{n}\sum D_i, the time-average number in queue q^(n)=1T∫0TQ(t) dt\hat q(n) = \frac{1}{T}\int_0^T Q(t)\, dt, and the server utilization u^(n)=1T∫0TB(t) dt\hat u(n) = \frac{1}{T}\int_0^T B(t)\, dt, where B(t)=1B(t) = 1 if the server is busy at time tt 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 ai=ai−1+Aia_i = a_{i-1} + A_i; start of service max⁡(ai,di−1)\max(a_i, d_{i-1}); delay Di=max⁡(0,di−1−ai)D_i = \max(0, d_{i-1} - a_i); departure di=ai+Di+Sid_i = a_i + D_i + S_i. Then list the event times in order, read off Q(t)Q(t) and B(t)B(t) between events, and add up the areas (time length × level).

Part II (3 questions)

  1. Output analysis (Chapter 6): construct a CI, and estimate the number of runs needed to achieve a given precision (absolute β\beta, or relative γ\gamma).
  2. Two questions on variance reduction (Chapter 7). For a given performance, measure:
    1. the variance of the crude Monte Carlo estimator (plain sampling, no variance reduction);
    2. 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 θ=E[eU]\theta = \mathbf{E}[e^U], two evaluations 0.1210.121 antithetic: 0.00390.0039 96.8%
§7.3 θ=E[eU]\theta = \mathbf{E}[e^U], one evaluation 0.2420.242 control variate UU: 0.00390.0039 98.4%
§7.5 E[eU]\mathbf{E}[e^U], 2n2n evaluations 0.242/2n0.242/2n stratified (two halves): 0.065/2n0.065/2n 73%
§7.7 P(10<X<11)P(10 < X < 11), X∼N(0,1)X \sim N(0, 1) ≈10−24/n\approx 10^{-24}/n importance sampling, g=N(10,1)g = N(10, 1): ≲10−44/n\lesssim 10^{-44}/n factor ≈1020\approx 10^{20}

Review
http://example.com/2026/09/08/2026-09-08-simulation-modeling-review/
Author
Wind_like
Posted on
September 8, 2026
Licensed under