6. Output Analysis

How to draw statistically valid conclusions from simulation output: transient versus steady-state behavior, confidence intervals for terminating simulations, and initial-data deletion, replication/deletion, batch means, regenerative and sequential methods for steady-state parameters.

flowchart LR
    ID(["input distributions"]) --> RV["random variates (rv's)"] --> P["simulation program"] --> Y["output random variables Y₁, Y₂, …"]

The inputs are random, so the outputs Y1,Y2,…Y_1, Y_2, \dots are random variables too. A performance measure is a statistic, i.e. a function of the output r.v.s:

h(Y1,Y2,… )  →  performance measure,e.g. h=Y1+⋯+Ynn.h(Y_1, Y_2, \dots) \;\to\; \text{performance measure}, \qquad \text{e.g. } h = \frac{Y_1 + \cdots + Y_n}{n} .

Wrong procedure in practice: perform a single simulation run of arbitrary length and treat the simulation estimates as the true characteristics of the system. Why it is wrong:

  • One run gives one realization of h(Y1,Y2,… )h(Y_1, Y_2, \dots), which is a random variable: a different seed gives a different answer, and a single number says nothing about how far it may be from the truth.
  • Within a run the YiY_i’s are not i.i.d. (see the example below), so the formulas of §2.6, which need i.i.d. data, cannot be applied to them.
  • With an arbitrary run length, the result can depend heavily on the initial conditions (§6.1).

Q: What is the correct way to estimate the true performance of the system based on simulation outputs?

Ex: queueing simulation. YiY_i = the delay of the ii-th customer. Lindley’s equation (§2.5):

Y1=0,Yi+1=max⁡{0, Yi+Si−Xi+1},Y_1 = 0, \qquad Y_{i+1} = \max\{0,\ Y_i + S_i - X_{i+1}\},

where SiS_i is the service time of customer ii and Xi+1X_{i+1} the interarrival time between customers ii and i+1i+1.

The YiY_i’s are not i.i.d.:

  • Not independent: Yi+1Y_{i+1} is computed from YiY_i. A customer who waits long is usually followed by another who waits long (positive correlation).
  • Not identically distributed: Y1=0Y_1 = 0 always (the system starts empty), Y2Y_2 is often 00, and the distribution of YiY_i keeps changing with ii (§6.1).

Solution: perform multiple replications, i.e. independent runs, each with the same initial conditions but its own independent random numbers (e.g. a different stream per run, §3.3).

output process Y1Y_1 Y2Y_2 ⋯\cdots YmY_m
run 1 Y11Y_{11} Y12Y_{12} ⋯\cdots Y1mY_{1m}
run 2 Y21Y_{21} Y22Y_{22} ⋯\cdots Y2mY_{2m}
⋮\vdots ⋮\vdots ⋮\vdots ⋮\vdots
run nn Yn1Y_{n1} Yn2Y_{n2} ⋯\cdots YnmY_{nm}

YikY_{ik} = the kk-th observation in run ii, a random observation obtained from a particular run. Along a row (within one run) the observations are dependent. Down a column (fixed kk, different runs), Y1k,Y2k,…,YnkY_{1k}, Y_{2k}, \dots, Y_{nk} are i.i.d., because the runs are independent copies of the same experiment. So

1n∑i=1nYikis an unbiased estimator of E[Yk],\frac{1}{n}\sum_{i=1}^n Y_{ik} \quad \text{is an unbiased estimator of } \mathbf{E}[Y_k],

and the usual i.i.d. statistics (CIs, §2.6) apply to each column.

Idea: use the observations in multiple runs to draw statistical inference about Y1,Y2,…,YmY_1, Y_2, \dots, Y_m.

6.1. Transient and Steady-State Behavior of a Stochastic Process

Output process Y1,Y2,…,Yj,…Y_1, Y_2, \dots, Y_j, \dots with Yj∼Fj(⋅∣I)Y_j \sim F_j(\cdot \mid I), where Fj(y∣I)=P(Yj≤y∣I)F_j(y \mid I) = P(Y_j \le y \mid I) and II is the initial condition (e.g. the number of customers present at time 0).

The fact that Fj(⋅∣I)F_j(\cdot \mid I) is different for different YjY_j’s is called the transient behavior; Fj(⋅∣I)F_j(\cdot \mid I) is the transient distribution of YjY_j. If there is a c.d.f. F(y)F(y) such that

Fj(y∣I)→F(y)as j→∞, for all y and all initial conditions I,F_j(y \mid I) \to F(y) \quad \text{as } j \to \infty, \text{ for all } y \text{ and all initial conditions } I,

then F(y)F(y) is called the steady-state distribution, and Y∼F(y)Y \sim F(y) is the steady-state random variable.

This is convergence in distribution (weak convergence, §2.4): Yj→dYY_j \xrightarrow{d} Y. What it means, and what it does not:

  • The limit FF does not depend on II: every initial condition leads to the same steady-state distribution. But how fast Fj(⋅∣I)F_j(\cdot \mid I) approaches FF does depend on II.
  • Strictly, FF is only reached as j→∞j \to \infty. In practice there is a kk such that Fj≈FF_j \approx F for all j>kj > k, and steady state is said to “start” around kk.
  • Steady state does not mean that the YjY_j’s stop changing or become equal within a run. It means that they have (approximately) the same distribution; they are still dependent on each other.

05101520150010001500jE[Yⱼ | I] (mean delay of customer j)steady-state mean E[Y] = 8.1I: first customer waits 20 (dashed)I: empty and idle (solid)

E.g. M/M/1 queue with ρ=0.9\rho = 0.9 (arrival rate 1, mean service time 0.9), averaged over 20,000 replications. Started empty and idle, the mean delay E[Yj∣I]\mathbf{E}[Y_j \mid I] rises from 0; started with a long first wait, it falls. Both approach the same steady-state mean E[Y]=8.1\mathbf{E}[Y] = 8.1, but only after several hundred customers. (The average delay of the first 25 customers from an empty start is about 2.12: a transient quantity, far from 8.1. It reappears in §6.3.2.)

6.2. Types of Simulations

  • terminating
  • nonterminating
    • steady-state parameters: Y1,Y2,⋯→YY_1, Y_2, \dots \to Y; characteristics of YY, e.g. E[Y]\mathbf{E}[Y], P(Y>s)P(Y > s), Var⁡(Y)\operatorname{Var}(Y)
    • steady-state cycle parameters

Terminating simulation

  • There is a natural event EE that determines the length of each simulation run.
  • Ex: simulate the operation of a retail store over an 8-hr shift; EE = {8 hours of simulated time have elapsed}.
  • Ex: a manufacturer receives a contract to produce 100 planes; EE = {100 planes have been completed}.
  • It never reaches steady state, and it does not need to: the run stops at EE, and the behavior up to EE, transient part included, is exactly what is being measured.
  • Both the initial conditions and the stopping event should be representative of the real system (e.g. the store opens empty every morning, so each run starts empty).

Nonterminating simulation

  • Any system that operates continuously, with no natural event EE to stop a run (e.g. a production line running around the clock).
  • Interested in long-run / steady-state behavior.
  • The initial condition does not matter: the steady-state distribution is the same for every II (§6.1).
  • Question: how long should the simulation be performed to ensure that the influence of the initial condition can be ignored? (In the figure of §6.1, several hundred customers.)
  • When the system is cyclic, we are interested in steady-state cycle parameters.

Ex: Y1,Y2,…,Y8Y_1, Y_2, \dots, Y_8, where YiY_i = server utilization in hour ii of an 8-hr shift at a bank (one that operates continuously, shift after shift). The hourly utilizations follow the same pattern in every shift (busy hours, quiet hours), so YiY_i never settles into one distribution: there is no steady state. Instead, look at whole cycles (shifts):

Yˉ1c=Y1+⋯+Y88  (average server utilization over shift 1),Yˉ2c=Y9+⋯+Y168, …\bar Y_1^c = \frac{Y_1 + \cdots + Y_8}{8} \ \ \text{(average server utilization over shift 1)}, \qquad \bar Y_2^c = \frac{Y_9 + \cdots + Y_{16}}{8}, \ \dots

The cycle averages Yˉ1c,Yˉ2c,…\bar Y_1^c, \bar Y_2^c, \dots can have a steady-state distribution, and

lim⁡n→∞E[Yˉnc]is a steady-state cycle parameter.\lim_{n \to \infty}\mathbf{E}\big[\bar Y_n^c\big] \quad \text{is a steady-state cycle parameter.}

6.3. Statistical Analysis for Terminating Simulations

Make nn independent replications of a terminating simulation: each replication starts with the same initial conditions, stops at the event EE, and uses its own independent random numbers. Let XjX_j be the performance measure from replication jj, i.e. a random variable computed from the outputs of run jj, for example

Xj=h(Yj1,…,Yjm)=average delay in queue of the customers in replication jX_j = h(Y_{j1}, \dots, Y_{jm}) = \text{average delay in queue of the customers in replication } j

(one XjX_j per row of the replication table at the start of the chapter). Since the replications are independent copies of the same experiment,

X1,X2,…,XnX_1, X_2, \dots, X_n are i.i.d.

Estimating means

Goal: to estimate μ=E[Xj]\mu = \mathbf{E}[X_j].

Xˉ(n)=1n∑j=1nXj\bar X(n) = \dfrac{1}{n}\sum_{j=1}^n X_j is an unbiased estimator for μ\mu.

A 100(1−α)%100(1-\alpha)\% CI for μ\mu is

[Xˉ(n)−tα/2, n−1S2(n)n,    Xˉ(n)+tα/2, n−1S2(n)n ]\left[\bar X(n) - t_{\alpha/2,\,n-1}\sqrt{\frac{S^2(n)}{n}},\;\; \bar X(n) + t_{\alpha/2,\,n-1}\sqrt{\frac{S^2(n)}{n}}\,\right]

(Case 2 of §2.6.1). It is exact if the XjX_j’s are normal, and approximate otherwise (see §6.3.2). Here

S2(n)=∑j=1n(Xj−Xˉ(n))2n−1S^2(n) = \frac{\sum_{j=1}^n \big(X_j - \bar X(n)\big)^2}{n-1}

is the sample variance of the XjX_j’s.

Ex: ten independent replications of a single-server queue model; XjX_j = the average delay in queue in replication jj:

Xj=2.02, 0.73, 3.20, 6.23, 1.76, 0.47, 3.89, 5.45, 1.44, 1.23.X_j = 2.02,\ 0.73,\ 3.20,\ 6.23,\ 1.76,\ 0.47,\ 3.89,\ 5.45,\ 1.44,\ 1.23 .

For α=0.1\alpha = 0.1: Xˉ(10)=2.64\bar X(10) = 2.64, S2(10)=3.96S^2(10) = 3.96, t0.05, 9=1.833t_{0.05,\,9} = 1.833, half-width 1.8333.96/10=1.151.833\sqrt{3.96/10} = 1.15, so a 90% CI is approximately [1.49, 3.79][1.49,\ 3.79].

6.3.1. Interpretation

“I am 95% sure that [9,11][9, 11] covers μ\mu”? No.

[9,11][9, 11] is an estimate: a fixed interval computed from one set of nn replications. μ\mu is a fixed (unknown) number, so [9,11][9, 11] either covers μ\mu or it does not; nothing random is left. The formula [Xˉ(n)±tα/2, n−1S2(n)/n]\big[\bar X(n) \pm t_{\alpha/2,\,n-1}\sqrt{S^2(n)/n}\big] is an estimator: a random interval, because Xˉ(n)\bar X(n) and S2(n)S^2(n) are random quantities. If the whole procedure is repeated many times (each time with nn new replications), you get [9,11][9, 11], [8.5,10.5][8.5, 10.5], …, and 95% of these intervals cover μ\mu. The 95% describes the procedure, not one particular interval.

misses μmisses μ89101112μ = 1040 realizations of the same 95% CI procedure (n = 10 each): 38 cover μ, 2 miss

6.3.2. Quality of CIs

The CI assumes normal XjX_j’s; when they are not normal, the actual coverage can be below 1−α1 - \alpha. To check, use test models whose μ\mu is known.

Ex: an M/M/1 queue (ρ=0.9\rho = 0.9, starting empty and idle; XjX_j = average delay in queue of the first 25 customers in replication jj):

μ=E[average delay in queue]=2.12.\mu = \mathbf{E}[\text{average delay in queue}] = 2.12 .

Construct 500 90% CIs for estimating μ\mu, each CI constructed based on nn simulation replications, and count the percentage of these 500 intervals that actually cover μ\mu.

nn actual coverage (500 CIs) simulation (20,000 CIs)
5 88% 83.5%
10 86% 85.8%
20 89% 88.1%
40 92% 89.1%

Ex: reliability example: a system of three components that fails when component 1 fails or when both components 2 and 3 have failed; the component lifetimes are i.i.d. Weibull (shape 0.5, scale 1). XjX_j = time to failure of the system in replication jj, and μ=0.78\mu = 0.78 (exactly 7/97/9). Perform the same experiment:

nn actual coverage (500 CIs) simulation (20,000 CIs)
5 71% 71.4%
10 75% 75.9%
20 80% 80.1%
40 84% 83.7%

A coverage value based on only 500 intervals is accurate to about ±2.6%\pm 2.6\% (the standard error of a proportion near 0.9 from 500 trials is 0.9×0.1/500=1.3%\sqrt{0.9 \times 0.1/500} = 1.3\%). So the small ups and downs in the first table (88% → 86% → 89% → 92%) are within this noise; with 20,000 intervals the coverage rises steadily toward 90% as nn grows.

The reliability coverage is lower. Why is there such a big difference?

Fact: the quality of the confidence interval depends on both nn and the nature of XjX_j. If XjX_j itself is the average of a large number of quantities, then the resulting CI in general has good coverage.

Why: the tt-interval is exact only for normal XjX_j; otherwise it relies on the CLT to make Xˉ(n)\bar X(n) approximately normal, and the further the distribution of XjX_j is from normal (especially the more skewed it is), the larger nn must be. In the M/M/1 example, XjX_j is an average of 25 delays and is already fairly close to normal (skewness 1.7). In the reliability example, XjX_j is a single time to failure, not an average: most systems fail almost immediately but a few last very long (skewness 5.3), far from normal.

-20246810M/M/1: X = average of 25 delaysμ = 2.12, skewness 1.7↑ off scale-20246reliability: X = one time to failureμ = 0.78, skewness 5.3bars: distribution of X (simulated); dashed: the normal curve with the same mean and variance

(The 25 delays within a run are positively correlated, so averaging them helps less than averaging 25 independent values would, but it still helps.)

6.3.3. Obtaining a specified precision

In the 100(1−α)%100(1-\alpha)\% CI  Xˉ(n)±tα/2, n−1S2(n)/n\ \bar X(n) \pm t_{\alpha/2,\,n-1}\sqrt{S^2(n)/n}:

  • Xˉ(n)\bar X(n) is the center;
  • 1−α1 - \alpha is the coverage probability;
  • nn is the sample size (number of replications);
  • δ=tα/2, n−1S2(n)/n\delta = t_{\alpha/2,\,n-1}\sqrt{S^2(n)/n} is the half-width of the CI, because the CI is [center−half-width, center+half-width][\text{center} - \text{half-width},\ \text{center} + \text{half-width}]. The half-width measures the precision: the smaller, the more precise.

If I increase 1−α1 - \alpha (α\alpha goes down), the tail area α/2\alpha/2 gets smaller, so the critical value tα/2, n−1t_{\alpha/2,\,n-1} is pushed to the right:

1.8332.2620pushed right1 − α = 0.90: tail area α/2 = 0.05 beyond t = 1.833 (light + dark)1 − α = 0.95: tail area α/2 = 0.025 beyond t = 2.262 (dark)higher confidence ⇒ smaller tail ⇒ larger t ⇒ wider CIdensity of t₉ (n = 10 replications)

However, if tt gets larger, the interval becomes wider and the precision is lower. If the range is too large, it is not informative: e.g. a 100% CI for a salary is [0,∞)[0, \infty), which is useless.

So for a fixed nn, more confidence costs precision. The way to get both is to increase nn: the half-width shrinks like 1/n1/\sqrt n (made precise in the procedures below).

Ex: two systems

  1. M/M/1, 2. M/D/1 (deterministic: every service time equals the mean service time of system 1). I want to do a comparison. Let DiD_i = average delay in queue in the ii-th system, i=1i = 1 or 22. Estimating D1−D2D_1 - D_2 is the comparison: which system has the smaller delay? Do this by simulation.

μ=E[D1−D2]=E[D1]−E[D2].\mu = \mathbf{E}[D_1 - D_2] = \mathbf{E}[D_1] - \mathbf{E}[D_2] .

Make nn replications of each system. Replication jj gives D1jD_{1j} and D2jD_{2j}; let

Zj=D1j−D2j,j=1,…,n.Z_j = D_{1j} - D_{2j}, \qquad j = 1, \dots, n .

The replications are independent, so Z1,…,ZnZ_1, \dots, Z_n are i.i.d. with mean μ\mu: this is exactly the setting of §6.3 (estimating means) with XjX_j replaced by ZjZ_j. So Zˉ(n)\bar Z(n) is an unbiased estimator of μ\mu, and with SZ2(n)S_Z^2(n) the sample variance of the ZjZ_j’s, a

95% CI for μ\mu is

[Zˉ(n)−t0.025, n−1SZ2(n)n,    Zˉ(n)+t0.025, n−1SZ2(n)n ],\left[\bar Z(n) - t_{0.025,\,n-1}\sqrt{\frac{S_Z^2(n)}{n}},\;\; \bar Z(n) + t_{0.025,\,n-1}\sqrt{\frac{S_Z^2(n)}{n}}\,\right],

and where it lies relative to 0 gives the answer:

01. CI entirely right of 0:μ > 0, E[D₁] > E[D₂]⇒ system 2 has smaller delay02. CI entirely left of 0:μ < 0, E[D₁] < E[D₂]⇒ system 1 has smaller delay03. CI contains 0:statistically insignificant⇒ cannot tell (yet)95% CI for μ = E[D₁ − D₂], and where 0 lies

  1. The CI lies entirely to the right of 0: μ>0\mu > 0, i.e. E[D1]>E[D2]\mathbf{E}[D_1] > \mathbf{E}[D_2], so system 2 has the smaller expected delay. The difference is statistically significant.
  2. The CI lies entirely to the left of 0: μ<0\mu < 0, so system 1 has the smaller expected delay.
  3. The CI contains 0: statistically insignificant. The data are consistent with μ=0\mu = 0, so we cannot tell which system is better. This does not show that μ=0\mu = 0; the interval may simply be too wide. The remedy is a smaller half-width, i.e. more replications. How many? That is what the procedures below answer.

E.g. both queues with ρ=0.9\rho = 0.9 (arrival rate 1, mean service time 0.9), started empty; DiD_i = average delay of the first 25 customers. With n=10n = 10 replications of each system: Zˉ(10)=1.48\bar Z(10) = 1.48, SZ2(10)=6.90S_Z^2(10) = 6.90, half-width 2.2626.90/10=1.882.262\sqrt{6.90/10} = 1.88, so the 95% CI is [−0.40, 3.36][-0.40,\ 3.36]. It contains 0: statistically insignificant (case 3), even though the true difference is μ=0.71\mu = 0.71 (system 2 is better).

Procedures for determining the number of replication runs

First case: α\alpha and β\beta (the desired half-width) are fixed; determine nn. Set the half-width equal to β\beta,

β=tα/2, n−1S2(n)n,\beta = t_{\alpha/2,\,n-1}\sqrt{\frac{S^2(n)}{n}},

and solve for nn:

n=S2(n) tα/2, n−12β2.n = \frac{S^2(n)\, t^2_{\alpha/2,\,n-1}}{\beta^2} .

Both sides contain nn (S2(n)S^2(n) and tα/2, n−1t_{\alpha/2,\,n-1} depend on it), so in practice: make n0n_0 pilot replications, use S2(n0)S^2(n_0) in place of S2(n)S^2(n), take the smallest nn with tα/2, n−1S2(n0)/n≤βt_{\alpha/2,\,n-1}\sqrt{S^2(n_0)/n} \le \beta, and make n−n0n - n_0 more replications. (For large nn, tα/2, n−1≈zα/2t_{\alpha/2,\,n-1} \approx z_{\alpha/2}, which gives n≈S2(n0) zα/22/β2n \approx S^2(n_0)\, z^2_{\alpha/2}/\beta^2 directly.)

Second case: α\alpha is fixed; reduce the half-width from β1\beta_1 (obtained with n1n_1 replications) to β2\beta_2. What is the additional number of replications needed?

β1=tα/2, n1−1S2(n1)n1,β2=tα/2, n2−1S2(n2)n2.\beta_1 = t_{\alpha/2,\,n_1-1}\sqrt{\frac{S^2(n_1)}{n_1}}, \qquad \beta_2 = t_{\alpha/2,\,n_2-1}\sqrt{\frac{S^2(n_2)}{n_2}} .

Assume S2(n2)≈S2(n1)S^2(n_2) \approx S^2(n_1) (both estimate the same variance) and tα/2, n2−1≈tα/2, n1−1t_{\alpha/2,\,n_2-1} \approx t_{\alpha/2,\,n_1-1}. Dividing,

β1β2≈n2n1⇒n2≈n1(β1β2)2,additional replications=n2−n1≈n1[(β1β2)2−1].\frac{\beta_1}{\beta_2} \approx \sqrt{\frac{n_2}{n_1}} \quad\Rightarrow\quad n_2 \approx n_1\left(\frac{\beta_1}{\beta_2}\right)^2, \qquad \text{additional replications} = n_2 - n_1 \approx n_1\left[\left(\frac{\beta_1}{\beta_2}\right)^2 - 1\right].

E.g. halving the half-width (β2=β1/2\beta_2 = \beta_1/2) needs n2=4n1n_2 = 4n_1, i.e. 3n13n_1 more replications. In fact tα/2, n−1t_{\alpha/2,\,n-1} decreases as nn grows, so this rule errs on the safe side.

E.g. (continued: α=0.05\alpha = 0.05, target half-width 0.50.5):

  • First case, with the pilot SZ2(10)=6.90S_Z^2(10) = 6.90: the smallest nn with t0.025, n−16.90/n≤0.5t_{0.025,\,n-1}\sqrt{6.90/n} \le 0.5 is n=109n = 109 (there t0.025, 108=1.98t_{0.025,\,108} = 1.98, and 6.90×1.982/0.52=108.46.90 \times 1.98^2/0.5^2 = 108.4).
  • Second case, from β1=1.88\beta_1 = 1.88 with n1=10n_1 = 10 to β2=0.5\beta_2 = 0.5: n2≈10 (1.88/0.5)2=141.2n_2 \approx 10\,(1.88/0.5)^2 = 141.2, i.e. about 132 more replications. More than 109, because the rule keeps tt at 2.2622.262 instead of letting it drop to about 1.981.98.

Running n=109n = 109 replications gives Zˉ(109)=0.95\bar Z(109) = 0.95, SZ2(109)=4.44S_Z^2(109) = 4.44, half-width 0.400.40, and the 95% CI [0.55, 1.35][0.55,\ 1.35]. It lies entirely to the right of 0 (case 1): the M/D/1 queue has the smaller expected delay. (The half-width came out below the target 0.5 because the pilot’s S2=6.90S^2 = 6.90 happened to be high: the procedures are only as good as the pilot’s variance estimate.)

n = 10[−0.40, 3.36]: contains 0 ⇒ statistically insignificantn = 109[0.55, 1.35]: excludes 0 ⇒ system 2 better-101230true μ = 0.71

Third scenario: precision is given in terms of the relative error. Fix α\alpha and the relative error γ\gamma; determine nn. Set the half-width relative to the size of the estimate equal to γ\gamma:

γ=tα/2, n−1S2(n)/n∣Xˉ(n)∣⇒n=S2(n) tα/2, n−12γ2 Xˉ(n)2.\gamma = \frac{t_{\alpha/2,\,n-1}\sqrt{S^2(n)/n}}{\left|\bar X(n)\right|} \quad\Rightarrow\quad n = \frac{S^2(n)\, t^2_{\alpha/2,\,n-1}}{\gamma^2\, \bar X(n)^2} .

What it means: the half-width is required to be at most a fraction γ\gamma of the estimate itself, so the CI is Xˉ(n) (1±γ)\bar X(n)\,(1 \pm \gamma); with γ=0.1\gamma = 0.1, “μ\mu is estimated to within about ±10%\pm 10\%”. This is useful when you do not know the scale of μ\mu in advance: an absolute half-width β=0.5\beta = 0.5 is very precise if μ≈100\mu \approx 100 but useless if μ≈0.3\mu \approx 0.3, while a relative error scales automatically. It is the first case with β\beta replaced by γ ∣Xˉ(n)∣\gamma\,|\bar X(n)|, and it is solved the same way, using Xˉ(n0)\bar X(n_0) and S2(n0)S^2(n_0) from a pilot run.

E.g. M/M/1 alone, μ=E[D1]=2.12\mu = \mathbf{E}[D_1] = 2.12: a pilot of n0=10n_0 = 10 replications gave Xˉ(10)=2.17\bar X(10) = 2.17 and S2(10)=3.44S^2(10) = 3.44. For α=0.05\alpha = 0.05 and γ=0.10\gamma = 0.10 the target half-width is 0.10×2.17=0.2170.10 \times 2.17 = 0.217, and the smallest nn with t0.025, n−13.44/n≤0.217t_{0.025,\,n-1}\sqrt{3.44/n} \le 0.217 is n=282n = 282 (formula: 3.44×1.9682/(0.12×2.172)=281.53.44 \times 1.968^2/(0.1^2 \times 2.17^2) = 281.5). In a simulation check, with 282 replications Xˉ\bar X was within 10% of μ\mu in 96% of repetitions.

Two cautions. (1) The relative error is measured against ∣Xˉ(n)∣|\bar X(n)|, not the unknown ∣μ∣|\mu|; to guarantee ∣Xˉ(n)−μ∣/∣μ∣≤γ|\bar X(n) - \mu|/|\mu| \le \gamma, the textbook uses the slightly smaller adjusted value γ/(1+γ)\gamma/(1+\gamma) in the formula. (2) Do not use a relative error for a quantity that may be close to 0, such as E[D1−D2]\mathbf{E}[D_1 - D_2] above: as Xˉ(n)→0\bar X(n) \to 0, the target half-width γ∣Xˉ(n)∣→0\gamma|\bar X(n)| \to 0 and the required nn explodes.

Common random numbers. Above, the two systems used independent random numbers. Feeding both systems the same interarrival times in each replication (common random numbers, §4.2.1 advantage 4) makes D1jD_{1j} and D2jD_{2j} positively correlated (here the correlation is about 0.5), and

Var⁡(Zj)=Var⁡(D1)+Var⁡(D2)−2cov⁡(D1,D2)\operatorname{Var}(Z_j) = \operatorname{Var}(D_1) + \operatorname{Var}(D_2) - 2\operatorname{cov}(D_1, D_2)

drops from 3.79 to 2.23 in this example. Since the required nn is proportional to the variance (first case), that is about 40% fewer replications for the same half-width.

6.3.4. Choosing initial conditions in terminating simulations

The initial conditions affect the results of a terminating simulation, so they must be representative of the real system (§6.2). In general there are two approaches.

Ex: estimate the expected average delay in queue of bank customers who arrive and complete their delays between noon and 1 pm.

Noon to 1 pm is the lunch rush, so at noon the bank is usually already busy. Starting the simulation empty and idle at noon would miss the customers already waiting then, and would underestimate the delays (as in the figure of §6.1, a queue started empty has smaller delays for a while).

Approach 1: start the simulation empty at 9 am (when the bank really opens, so “empty” is realistic), run the model for 3 hrs, reset the statistical counters at 12:00 noon and collect data for the next hr. The 9 am to noon part is a warm-up that builds up a realistic state at noon; its statistics are discarded.

Approach 2: collect data on the number of customers present at 12 noon (over many days), use the data to fit a distribution, and draw from that distribution to initialize the simulation at noon in each replication; then collect data from noon to 1 pm.

Approach 1warm-up from empty at 9 am (discarded)collect dataApproach 2collect datastart at noon with N(12) drawnfrom a distribution fitted to data9 am101112 noon1 pmreset statistical counters

  • Approach 1 needs no extra data, but every replication spends 3 simulated hours only to reach noon, and the arrivals during those hours must be modeled correctly (e.g. with a time-varying arrival rate, §4.6).
  • Approach 2 saves those 3 hours, but needs real data on the state at noon, and the number of customers may not describe the whole state (e.g. how much service the customers already in service still need; for exponential service times this does not matter, by the memoryless property).

In both approaches the replications stay i.i.d.: in approach 2, each replication draws its own initial number of customers independently.

6.3.5. Summary for terminating simulations

  1. We must perform multiple independent simulation runs (replications); a single run is not enough (start of this chapter).
  2. It is important to control the precision of the estimator, i.e. determine nn (§6.3.3).
  3. Initial conditions must be carefully chosen (§6.3.4).

6.4. Statistical Analysis for Steady-State Parameters (Non-Terminating)

Let Y1,Y2,…Y_1, Y_2, \dots be the output r.v.s of a nonterminating simulation. YiY_i converges to YY in distribution; more formally,

FYi(y)→FY(y)as i→∞, for all y,F_{Y_i}(y) \to F_Y(y) \quad \text{as } i \to \infty, \text{ for all } y,

where FYi(y)=P(Yi≤y)F_{Y_i}(y) = P(Y_i \le y) is the transient distribution of YiY_i (written Fi(y∣I)F_i(y \mid I) in §6.1) and FYF_Y is the steady-state distribution.

E[Y]\mathbf{E}[Y], P(Y>s)P(Y > s), Var⁡(Y)\operatorname{Var}(Y) are called steady-state parameters (§6.2): they are characteristics of the steady-state distribution FYF_Y. Goal: estimate a steady-state parameter, e.g. the steady-state mean

μ=E[Y]=lim⁡i→∞E[Yi].\mu = \mathbf{E}[Y] = \lim_{i \to \infty}\mathbf{E}[Y_i] .

Why is it difficult?

  • Problem of initial transience: E[Yi]≠E[Y]\mathbf{E}[Y_i] \ne \mathbf{E}[Y], because the early YiY_i’s come from transient distributions FYi≠FYF_{Y_i} \ne F_Y. So for the plain average of a run, Yˉ(m)=1m∑i=1mYi\bar Y(m) = \frac{1}{m}\sum_{i=1}^m Y_i, we get E[Yˉ(m)]≠E[Y]\mathbf{E}[\bar Y(m)] \ne \mathbf{E}[Y]: Yˉ(m)\bar Y(m) is a biased estimator of μ\mu (initialization bias). E.g. for the M/M/1 queue of §6.1 started empty (μ=8.1\mu = 8.1): E[Yˉ(100)]=4.13\mathbf{E}[\bar Y(100)] = 4.13, E[Yˉ(1000)]=7.30\mathbf{E}[\bar Y(1000)] = 7.30, E[Yˉ(10000)]=8.02\mathbf{E}[\bar Y(10000)] = 8.02. The bias shrinks only slowly as the run gets longer.
  • Within one run the YiY_i’s are correlated, so the i.i.d. CI of §2.6 cannot be applied to them directly. (§6.4.2–§6.4.4 are three ways around this.)

6.4.1. Initial-data deletion

Given observations Y1,Y2,…,YmY_1, Y_2, \dots, Y_m of a run, delete the first ll observations and use

Yˉ(m,l)=1m−l∑i=l+1mYi,1≤l≤m−1.\bar Y(m, l) = \frac{1}{m - l}\sum_{i=l+1}^{m} Y_i, \qquad 1 \le l \le m - 1 .

The deleted observations Y1,…,YlY_1, \dots, Y_l are the warm-up period (the same idea as the warm-up in approach 1 of §6.3.4); l=0l = 0 would give back the plain average Yˉ(m)\bar Y(m).

Is this a better estimator? Why? The deleted observations are the ones most affected by the initial condition (Y1=0Y_1 = 0 always, Y2Y_2 is often 00, …), i.e. the ones whose means E[Yi]\mathbf{E}[Y_i] are farthest from μ\mu. If the process is (approximately) in steady state after observation ll, every remaining YiY_i has E[Yi]≈μ\mathbf{E}[Y_i] \approx \mu, so E[Yˉ(m,l)]≈μ\mathbf{E}[\bar Y(m, l)] \approx \mu: the bias is (almost) removed. The price: Yˉ(m,l)\bar Y(m, l) averages only m−lm - l observations instead of mm, so its variance is larger. So it is better in bias, worse in variance.

Want E[Yˉ(m,l)]≈E[Y]\mathbf{E}[\bar Y(m, l)] \approx \mathbf{E}[Y]. How to choose ll? Trade-off:

  • if ll is small ⇒ high bias (transient observations are still included);
  • if ll is large ⇒ high variance (only a few observations are left).

E.g. the M/M/1 queue above, runs of length m=2000m = 2000 (bias computed numerically, standard deviations from 100,000 simulated runs):

ll bias E[Yˉ(m,l)]−μ\mathbf{E}[\bar Y(m, l)] - \mu standard deviation of Yˉ(m,l)\bar Y(m, l)
0 −0.405-0.405 3.3
100 −0.217-0.217 3.4
250 −0.110-0.110 3.6
500 −0.043-0.043 3.9
1000 −0.009-0.009 4.7
1500 −0.003-0.003 5.9

The bias matters more than these numbers suggest, because the variance can be reduced by making more runs and the bias cannot. With nn independent runs, the estimates Yˉ(m,l)\bar Y(m, l) of the runs are i.i.d., so they can be averaged and turned into a CI as in §6.3 (the replication/deletion approach, §6.4.2). Averaging divides the variance by nn, but the expectation stays E[Yˉ(m,l)]\mathbf{E}[\bar Y(m, l)] for every nn, so more runs only shrink the CI around the wrong value. E.g. with l=0l = 0, the 95% CI covered μ=8.1\mu = 8.1 in 83% of experiments with n=10n = 10 runs, 68% with n=100n = 100 and 26% with n=400n = 400; with l=500l = 500 it covered μ\mu in about 93% of experiments for both n=100n = 100 and n=400n = 400. So choose ll just large enough that the bias is negligible. That is what Welch’s procedure is for.

It is very difficult to determine ll from a single replication, because the observations are so variable: a value of ll that works well for one replication may be very bad for another. So Welch’s procedure uses several replications.

Welch’s procedure (for determining ll). Welch’s procedure chooses ll so that E[Yi]≈μ\mathbf{E}[Y_i] \approx \mu for i>li > l. The idea is to perform multiple runs, average across runs and then within runs (over neighboring observations) to construct a moving average process, plot the result and “eyeball” the value of ll.

  1. Make nn runs of the simulation (n≥5n \ge 5), each of length mm (mm much larger than the anticipated ll). As in the table at the start of the chapter, YjiY_{ji} = the ii-th observation of run jj:

Y1Y2⋯Ymrun 1Y11Y12⋯Y1mrun 2Y21Y22⋯Y2m⋮⋮⋮⋮run nYn1Yn2⋯Ynm\begin{array}{c|cccc} & Y_1 & Y_2 & \cdots & Y_m \\ \hline \text{run } 1 & Y_{11} & Y_{12} & \cdots & Y_{1m} \\ \text{run } 2 & Y_{21} & Y_{22} & \cdots & Y_{2m} \\ \vdots & \vdots & \vdots & & \vdots \\ \text{run } n & Y_{n1} & Y_{n2} & \cdots & Y_{nm} \end{array}

  1. Average across runs (down each column):

Yˉi=1n∑j=1nYji,i=1,…,m,E[Yˉi]=E[Yi].\bar Y_i = \frac{1}{n}\sum_{j=1}^{n} Y_{ji}, \qquad i = 1, \dots, m, \qquad \mathbf{E}[\bar Y_i] = \mathbf{E}[Y_i] .

Also Var⁡(Yˉi)=Var⁡(Yi)/n\operatorname{Var}(\bar Y_i) = \operatorname{Var}(Y_i)/n, since the runs are independent. So the averaged process Yˉ1,Yˉ2,…,Yˉm\bar Y_1, \bar Y_2, \dots, \bar Y_m has the same transient mean curve E[Yi]\mathbf{E}[Y_i] as a single run, which is what we want to see, but only 1/n1/n of the variance.
3. Construct a moving average process. Yˉi\bar Y_i still fluctuates a lot from one ii to the next; averaging neighboring values smooths out these fast fluctuations but keeps the slow trend E[Yi]\mathbf{E}[Y_i]. Specify the window w>0w > 0 (an integer, w≤⌊m/4⌋w \le \lfloor m/4 \rfloor) and let

Yˉi(w)={12w+1∑s=−wwYˉi+s,i=w+1,…,m−w,12i−1∑s=−(i−1)i−1Yˉi+s,i=1,…,w.\bar Y_i(w) = \begin{cases} \dfrac{1}{2w+1}\displaystyle\sum_{s=-w}^{w} \bar Y_{i+s}, & i = w+1, \dots, m-w,\\[2.5ex] \dfrac{1}{2i-1}\displaystyle\sum_{s=-(i-1)}^{i-1} \bar Y_{i+s}, & i = 1, \dots, w. \end{cases}

For i=w+1,…,m−wi = w+1, \dots, m-w, Yˉi(w)\bar Y_i(w) is the simple average of the 2w+12w+1 values Yˉi−w,…,Yˉi+w\bar Y_{i-w}, \dots, \bar Y_{i+w} centered at ii. For i≤wi \le w there are only i−1i - 1 values to the left of ii, so the window shrinks to i−1i - 1 values on each side: 2i−12i - 1 values, still centered at ii, so that the smoothed curve is not shifted. E.g. Yˉ1(w)=Yˉ1\bar Y_1(w) = \bar Y_1, Yˉ2(w)=13(Yˉ1+Yˉ2+Yˉ3)\bar Y_2(w) = \frac{1}{3}(\bar Y_1 + \bar Y_2 + \bar Y_3), Yˉ3(w)=15(Yˉ1+⋯+Yˉ5)\bar Y_3(w) = \frac{1}{5}(\bar Y_1 + \cdots + \bar Y_5). For i>m−wi > m - w there are fewer than ww values to the right, so Yˉi(w)\bar Y_i(w) is not defined there.

example: m = 16 observations, window w = 3 (w ≤ m/4 = 4)Yᵢ (step 2)12345678910111213141516i =i = 1, …, w: only i − 1 values exist left of i, so the window shrinks to 2i − 1 valuesi = 11 valuei = 23 valuesi = 3 = w5 valuesi = w + 1, …, m − w: full window of 2w + 1 values centered at ii = 4 = w + 17 valuesi = 97 valuesi = 13 = m − w7 values (the last one)= the i being smoothed; shaded = the values averaged into its moving averagei = 14, 15, 16 (> m − w): the window would run past m, so there is no moving average there

  1. Plot Yˉi(w)\bar Y_i(w) for i=1,2,…,m−wi = 1, 2, \dots, m - w and eyeball a cutoff value for ll: e.g. the value of ii such that beyond ii, Yˉi(w)\bar Y_i(w) does not change much (it appears to have converged).

E.g. the M/M/1 queue of §6.1 (ρ=0.9\rho = 0.9, started empty), m=2000m = 2000, w=100w = 100. This queue is very variable: with n=10n = 10 runs the moving average still swings between roughly 4 and 12, too much to see where it levels off, so n=100n = 100 runs were made. Yˉi(w)\bar Y_i(w) rises until about i=600i = 600 and after that only fluctuates around a constant level, so take l≈600l \approx 600. Since this is a test model, the choice can be checked: the bias of Yˉ(2000,600)\bar Y(2000, 600) is only −0.03-0.03, against −0.405-0.405 without deletion (table above).

048121500100015002000iμ= 8.1l≈ 600← transient: still risingdoes not change much →ends atm − w = 1900Yᵢ: average of the n = 100 runs (step 2)Yᵢ(w): moving average, w = 100 (step 3)

Choosing ww and nn: plot Yˉi(w)\bar Y_i(w) for several values of ww and use the smallest ww for which the plot is reasonably smooth. If ww is too small, the plot is ragged and it is hard to see where it levels off; if ww is too large, the rise is smeared out and the shape of the transient is lost. If no ww gives a smooth plot, make more runs and repeat step 2 with all of them (Var⁡(Yˉi)=Var⁡(Yi)/n\operatorname{Var}(\bar Y_i) = \operatorname{Var}(Y_i)/n shrinks). Eyeballing is subjective; when in doubt, take ll a little larger, since extra variance can be fixed with more runs but bias cannot.

6.4.2. Replication/deletion approach for means

Once a good cutoff value (warm-up period) ll has been determined, the analysis proceeds like the terminating-simulation analysis of §6.3:

  • make nn independent replications, each of length m′m' and each with warm-up period ll;
  • compute the mean and variance estimates across replications;
  • construct confidence intervals;
  • often, use nn pilot runs to determine the warm-up period (Welch’s procedure, §6.4.1) and then throw away the first ll observations from the new production runs.

In formulas: from replication jj keep only the observations after the warm-up and average them,

Xj=Yˉj(m′,l)=1m′−l∑i=l+1m′Yji,j=1,…,n,X_j = \bar Y_j(m', l) = \frac{1}{m' - l}\sum_{i=l+1}^{m'} Y_{ji}, \qquad j = 1, \dots, n,

then compute Xˉ(n)\bar X(n) and S2(n)S^2(n) from X1,…,XnX_1, \dots, X_n, and the 100(1−α)%100(1-\alpha)\% CI for μ\mu is

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

Why this works: the XjX_j’s are i.i.d., because the runs are independent copies of the same experiment (same initial conditions, separate random-number streams), and E[Xj]≈μ\mathbf{E}[X_j] \approx \mu, because the warm-up period was deleted. So the XjX_j’s play exactly the role of the XjX_j’s of §6.3, and everything there applies: the CI, its interpretation (§6.3.1), its quality (§6.3.2), and the procedures for choosing nn for a desired precision (§6.3.3). The correlation within a run no longer causes trouble: it is hidden inside each XjX_j, and only the XjX_j’s, one per run, enter the CI.

The production runs should be much longer than the warm-up (m′≫lm' \gg l); they can be longer than the pilot runs.

E.g. the M/M/1 queue (ρ=0.9\rho = 0.9, started empty, μ=8.1\mu = 8.1) with l=600l = 600 from Welch’s procedure. n=10n = 10 production runs of length m′=5000m' = 5000 gave

Xj=6.68, 9.13, 6.34, 10.06, 6.36, 6.90, 6.71, 9.70, 9.50, 5.61,X_j = 6.68,\ 9.13,\ 6.34,\ 10.06,\ 6.36,\ 6.90,\ 6.71,\ 9.70,\ 9.50,\ 5.61,

Xˉ(10)=7.699\bar X(10) = 7.699, S2(10)=2.836S^2(10) = 2.836, half-width 2.2622.836/10=1.202.262\sqrt{2.836/10} = 1.20, so the 95% CI is [6.49, 8.90][6.49,\ 8.90], which covers μ\mu. Repeating the whole experiment 2000 times, the CI covered μ\mu in 91.6% of experiments with n=10n = 10 and 93.6% with n=20n = 20 (without deletion, l=0l = 0: 89.0% and 89.2%). The remaining shortfall from 95% is the skewness of the XjX_j’s, as in §6.3.2.

Pros and cons:

  • + Simple: it is the familiar i.i.d. analysis, and the XjX_j’s are truly independent.
  • − Every run has to pass through the transient: n×ln \times l observations are thrown away (here 10×600=600010 \times 600 = 6000 out of 50,00050{,}000).
  • − If ll is chosen too small, the remaining bias is in every XjX_j and does not average out over the runs (§6.4.1).

The second point motivates the batch means method: use one run, so the transient is passed only once.

6.4.3. The batch means method

The batch means method is the most popular alternative to replication/deletion. The idea is to perform one very long simulation run and estimate the steady-state parameters from that single run by dividing the output into batches.

Make one simulation run of length mm, with mm very large. Divide the observations Y1,Y2,…,YmY_1, Y_2, \dots, Y_m into nn batches of size kk, so that m=nkm = nk:

Y1,…,Yk⏟batch 1, Yk+1,…,Y2k⏟batch 2, …, Y(n−1)k+1,…,Ynk⏟batch n.\underbrace{Y_1, \dots, Y_k}_{\text{batch } 1},\ \underbrace{Y_{k+1}, \dots, Y_{2k}}_{\text{batch } 2},\ \dots,\ \underbrace{Y_{(n-1)k+1}, \dots, Y_{nk}}_{\text{batch } n} .

(Here nn is the number of batches, not the number of runs: there is only one run.) Let

Yˉj(k)=1k∑i=(j−1)k+1jkYi\bar Y_j(k) = \frac{1}{k}\sum_{i=(j-1)k+1}^{jk} Y_i

be the sample mean of the kk observations in the jj-th batch. Then Yˉ1(k),Yˉ2(k),…,Yˉn(k)\bar Y_1(k), \bar Y_2(k), \dots, \bar Y_n(k) are the batch means. Let

Yˉ(n,k)=1n∑j=1nYˉj(k)\bar Y(n, k) = \frac{1}{n}\sum_{j=1}^n \bar Y_j(k)

be the grand sample mean. This is used as a point estimator of E[Y]\mathbf{E}[Y]. Note that

Yˉ(n,k)=1n∑j=1nYˉj(k)=1n∑j=1n1k∑i∈batch jYi=1nk∑i=1mYi=1m∑i=1mYi:\bar Y(n, k) = \frac{1}{n}\sum_{j=1}^n \bar Y_j(k) = \frac{1}{n}\sum_{j=1}^n \frac{1}{k}\sum_{i \in \text{batch } j} Y_i = \frac{1}{nk}\sum_{i=1}^m Y_i = \frac{1}{m}\sum_{i=1}^m Y_i :

since all batches have the same size, the average of the batch means is just the average of all mm observations. Batching does not change the point estimate; it is needed only to estimate its variance.

When mm is large, the influence of the initial condition dies out: the biased early observations are only a small fraction of the mm observations. (One can also delete a warm-up period first and batch the rest, as in the figure and the example below.)

010203040110.025.639.246.853.665.9710.989.493.2107.9batch j = 1, …, 10 (k = 1000 observations each)warm-up (deleted)μ= 8.1batch mean:one run: delays Yᵢ, i = 1, …, 10,600Yⱼ(k): batch mean of batch j

If kk is large enough, then the batch means Yˉj(k)\bar Y_j(k) will be approximately uncorrelated and approximately normally distributed. Why:

  • Uncorrelated: YiY_i and Yi+hY_{i+h} are correlated, but the correlation dies out as the lag hh grows. Two neighboring batches are correlated only through the observations near their common boundary (the end of one batch and the beginning of the next). When kk is much longer than the “memory” of the process, these are a small part of each batch, so the correlation between batch means is small.
  • Normal: each batch mean is an average of kk observations; by a central limit theorem for correlated observations, it is approximately normal for large kk (the same reason as in §6.3.2, where an XjX_j that is an average of many observations gave good coverage).

For normal random variables, uncorrelated plus jointly normal implies independence. Thus, for sufficiently large kk, it is reasonable to treat the batch means as i.i.d. normal random variables and construct confidence intervals for E[Y]\mathbf{E}[Y] exactly as in §6.3, with the batch means in the role of the XjX_j’s. An estimate of the variance (of one batch mean) is

SYˉ2=∑j=1n(Yˉj(k)−Yˉ(n,k))2n−1,S_{\bar Y}^2 = \frac{\sum_{j=1}^n \big(\bar Y_j(k) - \bar Y(n, k)\big)^2}{n - 1},

and the 100(1−α)%100(1-\alpha)\% CI for E[Y]\mathbf{E}[Y] is

Yˉ(n,k)±tα/2, n−1SYˉ2n.\bar Y(n, k) \pm t_{\alpha/2,\,n-1}\sqrt{\frac{S_{\bar Y}^2}{n}} .

Why not simply treat the mm observations YiY_i themselves as i.i.d., and use their sample variance divided by mm? Because they are positively correlated, Var⁡(Yˉ(m))\operatorname{Var}(\bar Y(m)) is much larger than Var⁡(Y)/m\operatorname{Var}(Y)/m (positive covariances add to the variance of a sum: Var⁡(Y1+⋯+Ym)=∑iVar⁡(Yi)+2∑i<i′cov⁡(Yi,Yi′)\operatorname{Var}(Y_1 + \cdots + Y_m) = \sum_i \operatorname{Var}(Y_i) + 2\sum_{i < i'}\operatorname{cov}(Y_i, Y_{i'}), §2.3), so that CI would be far too narrow. In the M/M/1 example below (m=120,000m = 120{,}000), the naive i.i.d. 95% CI has an average half-width of only 0.05, while the actual standard deviation of Yˉ(m)\bar Y(m) is 0.49: the naive standard error is about 19 times too small, and the naive CI covered μ\mu in only 9% of experiments. Batching fixes this because each batch mean already contains the effect of the correlation within its batch.

Choosing the batch size. The advantage of batch means is that the initial transient is encountered only once. The difficulty is choosing the batch size kk (for a fixed mm, choosing kk is the same as choosing the number of batches n=m/kn = m/k):

  • If kk is too small, the batch means are highly correlated and SYˉ2S_{\bar Y}^2 can be a poor estimator. (Positively correlated batch means look less spread out than independent ones would, so SYˉ2S_{\bar Y}^2 underestimates the variance and the CI is too narrow.)
  • If kk is too large, there are fewer batches and the variance of the variance estimator is large: SYˉ2S_{\bar Y}^2 is based on only a few batch means and tα/2, n−1t_{\alpha/2,\,n-1} is large, so the CI is wide and unstable.

A rule of thumb is that there is little benefit from more than 30 batches, but there should not be fewer than 10:

10≤n≤30.10 \le n \le 30 .

Why: M/M/1 (ρ=0.9\rho = 0.9), warm-up 600 deleted, then one run of m=120,000m = 120{,}000 cut into nn batches; 2000 repetitions, 95% CIs:

batches nn batch size kk correlation of neighboring batch means t0.025, n−1t_{0.025,\,n-1} average half-width coverage
5 24,000 0.01 2.776 1.26 94.2%
10 12,000 0.02 2.262 1.04 93.3%
20 6,000 0.01 2.093 0.97 93.4%
30 4,000 0.03 2.045 0.95 93.2%
50 2,400 0.05 2.010 0.92 93.0%
100 1,200 0.11 1.984 0.86 91.1%
300 400 0.33 1.968 0.71 85.3%
600 200 0.51 1.964 0.58 76.9%

From 5 to about 20–30 batches, the CI gets narrower (the critical value drops from 2.78 to about 2.05, and SYˉ2S_{\bar Y}^2 is based on more batch means) at no cost in coverage. Beyond about 30, tα/2, n−1t_{\alpha/2,\,n-1} hardly changes any more (it is already close to z0.025=1.96z_{0.025} = 1.96), so there is little left to gain; the further narrowing comes from correlated batch means making SYˉ2S_{\bar Y}^2 too small, and the coverage drops.

E.g. one run of the M/M/1 queue: warm-up 600 deleted, then m=120,000m = 120{,}000 in n=20n = 20 batches of k=6000k = 6000: Yˉ(20,6000)=7.518\bar Y(20, 6000) = 7.518, SYˉ2=2.268S_{\bar Y}^2 = 2.268, half-width 2.0932.268/20=0.702.093\sqrt{2.268/20} = 0.70, so the 95% CI is [6.81, 8.22][6.81,\ 8.22], which covers μ=8.1\mu = 8.1.

6.4.4. Regenerative method

The regenerative method is similar in spirit to batch means. It tries to construct independent replications from a single run, using regeneration points. The difference: batch means cut the run at fixed places (every kk observations), so the pieces are only approximately independent; the regenerative method cuts the run at random places chosen so that the pieces are exactly i.i.d.

A regeneration point is a random time at which the process probabilistically restarts itself: from that time on, the process behaves (in distribution) exactly as if it had just been started, independently of what happened before. The process between two successive regeneration points is called a regeneration cycle.

Ex: single-server queue. A customer who arrives to an empty system finds the same situation every time: nobody waiting, the server idle, and the customer starts service at once. Everything after that (the following interarrival times and service times) is new and independent of the past. So the arrival times of customers who find the system empty are regeneration points. In terms of the delays, these are exactly the customers with Yi=0Y_i = 0. A run started empty has Y1=0Y_1 = 0, so it starts at a regeneration point.

Suppose the output process Y1,Y2,…Y_1, Y_2, \dots has regeneration points

1≤B1<B2<⋯ .1 \le B_1 < B_2 < \cdots .

At each regeneration point, the process after BjB_j is independent of the process prior to BjB_j. Let

Nj=Bj+1−BjN_j = B_{j+1} - B_j

be the length of the jj-th cycle (the number of observations in it), and let

Zj=∑i=BjBj+1−1YiZ_j = \sum_{i=B_j}^{B_{j+1}-1} Y_i

be the sum of the observations in the jj-th cycle.

012345Yᵢ = delay of customer i151015202529icycle 1N₁ = 5Z₁ = 4.65cycle 2: N₂ = 1, Z₂ = 0cycle 3N₃ = 8Z₃ = 11.18cycle 4N₄ = 12Z₄ = 31.48cycle 5: N₅ = 2, Z₅ = 0.11B₁B₂B₃B₄B₅B₆regeneration point: a customer who arrives to an empty system (Yᵢ = 0); the next cycle starts there

In the queue, cycle jj consists of the customers served in one busy period: NjN_j = number of customers served in the busy period, ZjZ_j = their total delay. A cycle with Nj=1N_j = 1 is a customer who arrives to an empty system and leaves before the next arrival, so Zj=0Z_j = 0.

Then

Uj=(Zj,Nj)TU_j = (Z_j, N_j)^T

are i.i.d. bivariate random variables: different cycles are independent copies (each cycle starts from a fresh restart), but within a cycle ZjZ_j and NjN_j are dependent (a long busy period, large NjN_j, also has large delays, large ZjZ_j).

By the renewal-reward theorem,

μ=E[Y]=lim⁡m→∞∑i=1mYim=E[Zj]E[Nj],for all j.\mu = \mathbf{E}[Y] = \lim_{m \to \infty}\frac{\sum_{i=1}^m Y_i}{m} = \frac{\mathbf{E}[Z_j]}{\mathbf{E}[N_j]}, \qquad \text{for all } j.

This is the long-run average cost or reward per unit time: each cycle earns a “reward” ZjZ_j and takes “time” NjN_j (counted in observations). Why it holds: over the first n′n' cycles there are N1+⋯+Nn′N_1 + \cdots + N_{n'} observations with total Z1+⋯+Zn′Z_1 + \cdots + Z_{n'}, so their average is

Z1+⋯+Zn′N1+⋯+Nn′=1n′∑jZj1n′∑jNj  →  E[Zj]E[Nj]as n′→∞,\frac{Z_1 + \cdots + Z_{n'}}{N_1 + \cdots + N_{n'}} = \frac{\frac{1}{n'}\sum_j Z_j}{\frac{1}{n'}\sum_j N_j} \;\to\; \frac{\mathbf{E}[Z_j]}{\mathbf{E}[N_j]} \quad \text{as } n' \to \infty,

by the SLLN (§2.4) applied separately to the i.i.d. ZjZ_j’s and the i.i.d. NjN_j’s. E.g. in the M/M/1 queue, a busy period serves on average E[Nj]=1/(1−ρ)=10\mathbf{E}[N_j] = 1/(1-\rho) = 10 customers, so E[Zj]=μ E[Nj]=81\mathbf{E}[Z_j] = \mu\,\mathbf{E}[N_j] = 81.

Assume we simulate exactly n′n' regeneration cycles. Let

Zˉ(n′)=1n′∑j=1n′Zj,Nˉ(n′)=1n′∑j=1n′Nj.\bar Z(n') = \frac{1}{n'}\sum_{j=1}^{n'} Z_j, \qquad \bar N(n') = \frac{1}{n'}\sum_{j=1}^{n'} N_j .

A point estimator of μ\mu is

μ^(n′)=Zˉ(n′)Nˉ(n′).\hat\mu(n') = \frac{\bar Z(n')}{\bar N(n')} .

This estimator is biased, because the expected value of a ratio is not the ratio of the expected values:

E[Zˉ(n′)Nˉ(n′)]≠E[Zˉ(n′)]E[Nˉ(n′)]=μ,\mathbf{E}\left[\frac{\bar Z(n')}{\bar N(n')}\right] \ne \frac{\mathbf{E}[\bar Z(n')]}{\mathbf{E}[\bar N(n')]} = \mu,

but it is strongly consistent:

μ^(n′)→μwith probability 1 as n′→∞\hat\mu(n') \to \mu \quad \text{with probability 1 as } n' \to \infty

(this is the calculation above). In the M/M/1 example, the average of μ^(n′)\hat\mu(n') over many runs was 6.97 for n′=100n' = 100 cycles, 7.93 for n′=1000n' = 1000 and 8.08 for n′=5000n' = 5000: a large bias for few cycles, disappearing as n′n' grows.

Confidence interval. The problem: μ^\hat\mu is a ratio of two averages, so the CLT cannot be applied to it directly. The trick is to turn the ratio into an average. Let Σ\Sigma be the covariance matrix of Uj=(Zj,Nj)TU_j = (Z_j, N_j)^T:

Σ=(σ11σ12σ21σ22),σ11=Var⁡(Zj),σ22=Var⁡(Nj),σ12=σ21=E[(Zj−E[Zj])(Nj−E[Nj])].\Sigma = \begin{pmatrix} \sigma_{11} & \sigma_{12} \\ \sigma_{21} & \sigma_{22} \end{pmatrix}, \qquad \sigma_{11} = \operatorname{Var}(Z_j),\quad \sigma_{22} = \operatorname{Var}(N_j),\quad \sigma_{12} = \sigma_{21} = \mathbf{E}\big[(Z_j - \mathbf{E}[Z_j])(N_j - \mathbf{E}[N_j])\big].

Let

Vj=Zj−μNj.V_j = Z_j - \mu N_j .

The VjV_j’s are i.i.d. (functions of the i.i.d. UjU_j’s), and

E[Vj]=E[Zj]−μ E[Nj]=0\mathbf{E}[V_j] = \mathbf{E}[Z_j] - \mu\,\mathbf{E}[N_j] = 0

because μ=E[Zj]/E[Nj]\mu = \mathbf{E}[Z_j]/\mathbf{E}[N_j], and

σV2=Var⁡(Vj)=Var⁡(Zj−μNj)=σ11−2μσ12+μ2σ22\sigma_V^2 = \operatorname{Var}(V_j) = \operatorname{Var}(Z_j - \mu N_j) = \sigma_{11} - 2\mu\sigma_{12} + \mu^2\sigma_{22}

(the variance of a linear combination: Var⁡(aZ+bN)=a2Var⁡(Z)+2abcov⁡(Z,N)+b2Var⁡(N)\operatorname{Var}(aZ + bN) = a^2\operatorname{Var}(Z) + 2ab\operatorname{cov}(Z, N) + b^2\operatorname{Var}(N) with a=1a = 1, b=−μb = -\mu). By the central limit theorem,

Vˉ(n′)σV2/n′≈N(0,1),Vˉ(n′)=1n′∑j=1n′Vj.\frac{\bar V(n')}{\sqrt{\sigma_V^2/n'}} \approx N(0, 1), \qquad \bar V(n') = \frac{1}{n'}\sum_{j=1}^{n'} V_j .

Why this gives a CI for μ\mu: the average of the VjV_j’s is

Vˉ(n′)=Zˉ(n′)−μ Nˉ(n′)=Nˉ(n′)(μ^(n′)−μ),\bar V(n') = \bar Z(n') - \mu\,\bar N(n') = \bar N(n')\big(\hat\mu(n') - \mu\big),

so the statement above says

μ^(n′)−μσV2/n′ / Nˉ(n′)≈N(0,1),\frac{\hat\mu(n') - \mu}{\sqrt{\sigma_V^2/n'}\,\big/\,\bar N(n')} \approx N(0, 1),

i.e. μ^(n′)\hat\mu(n') is approximately normal around μ\mu with standard deviation σV2/n′/Nˉ(n′)\sqrt{\sigma_V^2/n'}/\bar N(n').

Since σV2\sigma_V^2 is unknown, estimate it using the sample covariance matrix

Σ^(n′)=∑j=1n′(Uj−Uˉ(n′))(Uj−Uˉ(n′))Tn′−1=(σ^11(n′)σ^12(n′)σ^21(n′)σ^22(n′)),\hat\Sigma(n') = \frac{\sum_{j=1}^{n'}\big(U_j - \bar U(n')\big)\big(U_j - \bar U(n')\big)^T}{n' - 1} = \begin{pmatrix} \hat\sigma_{11}(n') & \hat\sigma_{12}(n') \\ \hat\sigma_{21}(n') & \hat\sigma_{22}(n') \end{pmatrix},

where Uˉ(n′)=(Zˉ(n′),Nˉ(n′))T\bar U(n') = (\bar Z(n'), \bar N(n'))^T; so σ^11\hat\sigma_{11} is the sample variance of the ZjZ_j’s, σ^22\hat\sigma_{22} the sample variance of the NjN_j’s, and σ^12\hat\sigma_{12} their sample covariance. Then, with μ^(n′)\hat\mu(n') in place of the unknown μ\mu,

σ^V2(n′)=σ^11(n′)−2μ^(n′)σ^12(n′)+[μ^(n′)]2σ^22(n′).\hat\sigma_V^2(n') = \hat\sigma_{11}(n') - 2\hat\mu(n')\hat\sigma_{12}(n') + \big[\hat\mu(n')\big]^2\hat\sigma_{22}(n') .

An approximate 100(1−α)%100(1-\alpha)\% confidence interval for μ\mu is

[μ^(n′)−zα/2σ^V2(n′)/n′Nˉ(n′),    μ^(n′)+zα/2σ^V2(n′)/n′Nˉ(n′)].\left[\hat\mu(n') - z_{\alpha/2}\frac{\sqrt{\hat\sigma_V^2(n')/n'}}{\bar N(n')},\;\; \hat\mu(n') + z_{\alpha/2}\frac{\sqrt{\hat\sigma_V^2(n')/n'}}{\bar N(n')}\right].

(zz, not tt: the whole result is a large-n′n' approximation.)

E.g. one run of the M/M/1 queue, started empty, n′=1000n' = 1000 cycles (8438 customers). The first cycles were (Zj,Nj)=(77.35,18),(0,1),(0,1),(0.35,2),(30.99,11),(3.07,7),…(Z_j, N_j) = (77.35, 18), (0, 1), (0, 1), (0.35, 2), (30.99, 11), (3.07, 7), \dots Over all 1000 cycles: Zˉ=66.695\bar Z = 66.695, Nˉ=8.438\bar N = 8.438, so μ^=66.695/8.438=7.904\hat\mu = 66.695/8.438 = 7.904; σ^11=396,988\hat\sigma_{11} = 396{,}988, σ^12=22,976\hat\sigma_{12} = 22{,}976, σ^22=1431.8\hat\sigma_{22} = 1431.8, so

σ^V2=396,988−2(7.904)(22,976)+7.9042(1431.8)≈123,230,\hat\sigma_V^2 = 396{,}988 - 2(7.904)(22{,}976) + 7.904^2(1431.8) \approx 123{,}230,

half-width=1.96 123,230/10008.438=2.58,\text{half-width} = 1.96\,\frac{\sqrt{123{,}230/1000}}{8.438} = 2.58,

and the 95% CI is [5.33, 10.48][5.33,\ 10.48]. It covers μ=8.1\mu = 8.1 but is wide. Over many runs, this CI covered μ\mu in 55% of runs with n′=100n' = 100 cycles, 81% with n′=1000n' = 1000 and 91% with n′=5000n' = 5000. The cycles of this queue are extremely variable (most busy periods are short, a few are very long with huge ZjZ_j), so the ratio estimator is biased and the normal approximation is poor unless there are many cycles.

Difficulty of the regenerative method: many processes may not have regeneration points. Even if they do, the expected cycle length may be so large that only a few cycles can be simulated (e.g. in a large network of queues, the moment when all queues are empty at the same time is rare).

Ex: single-server queue regeneration points. Possible regeneration points include the arrival times of customers who find the system empty (above). Two choices that do not work:

  • Times immediately after busy cycles end (the moment the system becomes empty) are not good regeneration points if the time until the next arrival is not identically distributed. At that moment the next arrival is already “on its way”: the remaining time until it depends on how long ago the previous arrival happened, which differs from one busy period to the next. (Only for exponential interarrival times does this not matter, by the memoryless property.) An arrival to an empty system, by contrast, starts a brand-new interarrival time.
  • Arrival times of customers who find one customer in the system are also not regeneration points, because the remaining service time of the customer in service is differently distributed: it depends on how long that service has already been going on. The process after such an arrival is not a fresh copy.

What the regenerative method offers in exchange: if the run starts at a regeneration point (e.g. an empty queue), there is no initial transient problem at all, there is no batch size to choose, and the cycles are exactly i.i.d.

6.4.5. Sequential procedure

A sequential procedure sequentially determines the length of a single run needed to construct an acceptable confidence interval.

Explanation. In §6.3.3 we chose the number of replications nn to reach a desired precision. For a single long run (e.g. batch means), the corresponding question is: how long must the run be? This cannot be computed in advance, because the variance of Yˉ(m)\bar Y(m) depends on the unknown correlation structure of the process. A sequential procedure decides while the run is going. One simple version:

  1. Run the simulation for an initial length m1m_1 (after the warm-up).
  2. Construct a CI from the data so far, e.g. by batch means with a fixed number of batches.
  3. If the CI is acceptable (e.g. its relative half-width is at most γ\gamma, as in §6.3.3), stop. Otherwise continue the same run to a longer length (e.g. double it) and go back to step 2.

(The procedures in the textbook are more refined, e.g. they also check that the batch means are approximately uncorrelated before accepting the CI.)

E.g. M/M/1 queue, warm-up 600, 20 batches, start at m=10,000m = 10{,}000 and double mm until the 95% CI has relative half-width ≤γ=0.1\le \gamma = 0.1. Over 2000 repetitions the procedure stopped at m=80,000m = 80{,}000 (9% of runs), 160,000160{,}000 (41%), 320,000320{,}000 (44%) or 640,000640{,}000 (5%), and rarely earlier. The estimate was within 10% of μ\mu in 95.8% of runs, but the final CI covered μ\mu in only 90.2% (with a fixed m=320,000m = 320{,}000: 94.8%). The stopping rule is slightly optimistic: it tends to stop at moments when SYˉ2S_{\bar Y}^2 happens to be small, i.e. when the CI happens to look narrow.

6.4.6. Summary for steady-state simulations

The problem (§6.4): within one run the observations are correlated and the early ones are biased. All methods construct (approximately) i.i.d. pieces and then use the i.i.d. analysis of §6.3:

replication/deletionn runs of length m′;delete l in every runrun 1X₁run 2X₂run 3X₃run nXₙ→ one Xⱼ per runln warm-ups; X₁, …, Xₙ exactly i.i.d.batch meansone long run of length m;n batches of size kY₁(k)Y₂(k)Y₃(k)Y₄(k)Y₅(k)Y₆(k)Y₇(k)Yₙ(k)warm-upone warm-up; equal batch lengths k; batch means only approximately i.i.d. (k must be large)regenerativeone run, cut at theregeneration points12(Z₃, N₃)4(Z₅, N₅)6(Z₇, N₇)8no warm-up if started at a regeneration point; random cycle lengths Nⱼ; cycles exactly i.i.d.

method runs warm-up i.i.d. pieces CI main difficulty
replication/deletion (§6.4.2) nn independent runs deleted in every run (ll from Welch, §6.4.1) Xj=Yˉj(m′,l)X_j = \bar Y_j(m', l), exactly i.i.d. tt-CI from the XjX_j’s choosing ll; the transient is paid nn times
batch means (§6.4.3) one long run passed once batch means Yˉj(k)\bar Y_j(k), approximately i.i.d. tt-CI from the batch means choosing kk (10≤n≤3010 \le n \le 30 batches)
regenerative (§6.4.4) one run none, if started at a regeneration point cycles (Zj,Nj)(Z_j, N_j), exactly i.i.d. ratio CI with zz needs regeneration points; many cycles needed
sequential (§6.4.5) one run, extended as needed passed once e.g. batch means stops when the CI is precise enough stopping rule is slightly optimistic

6.5. Multiple Performance Measures

In practice, we are often interested in several performance measures simultaneously (e.g. the average delay in queue, the average number in queue and the server utilization of the same system). Thus we may construct several confidence intervals:

P(V1∈I1)=1−α1,P(V2∈I2)=1−α2,…,P(Vk∈Ik)=1−αk,P(V_1 \in I_1) = 1 - \alpha_1, \qquad P(V_2 \in I_2) = 1 - \alpha_2, \qquad \dots, \qquad P(V_k \in I_k) = 1 - \alpha_k,

where VsV_s is the true value of the ss-th performance measure and IsI_s is its CI. The question is how these individual confidence intervals affect the overall confidence level:

P(Vs∈Is for all s=1,…,k)= ?P(V_s \in I_s \text{ for all } s = 1, \dots, k) = \ ?

This is the probability that all kk confidence intervals simultaneously contain their corresponding performance measures. It matters whenever conclusions are drawn from all the intervals together (“the delay is in I1I_1 and the utilization is in I2I_2”).

If the performance measures (more precisely, their CIs) are independent, then

P(Vs∈Is, ∀s)=∏s=1kP(Vs∈Is)=(1−α1)(1−α2)⋯(1−αk).P(V_s \in I_s,\ \forall s) = \prod_{s=1}^k P(V_s \in I_s) = (1 - \alpha_1)(1 - \alpha_2)\cdots(1 - \alpha_k) .

E.g. three independent 95% CIs: 0.953=0.8570.95^3 = 0.857, so all three are correct together only with probability 85.7%, not 95%.

In practice, however, performance measures are unlikely to be independent (they are computed from the same simulation runs). A conservative approach uses Bonferroni’s inequality, which holds for any dependence:

P(Vs∈Is, ∀s)=P(V1∈I1∩V2∈I2∩⋯∩Vk∈Ik)=1−P(V1∉I1∪V2∉I2∪⋯∪Vk∉Ik)≥1−∑s=1kP(Vs∉Is)≥1−∑s=1kαs.\begin{aligned} P(V_s \in I_s,\ \forall s) &= P(V_1 \in I_1 \cap V_2 \in I_2 \cap \cdots \cap V_k \in I_k) \\ &= 1 - P(V_1 \notin I_1 \cup V_2 \notin I_2 \cup \cdots \cup V_k \notin I_k) \\ &\ge 1 - \sum_{s=1}^k P(V_s \notin I_s) \\ &\ge 1 - \sum_{s=1}^k \alpha_s . \end{aligned}

Step by step:

  1. “All intervals are correct” is the intersection of the events {Vs∈Is}\{V_s \in I_s\}.
  2. Complement: its opposite, “at least one interval is wrong”, is the union of the events {Vs∉Is}\{V_s \notin I_s\} (De Morgan’s law), so P(all correct)=1−P(at least one wrong)P(\text{all correct}) = 1 - P(\text{at least one wrong}).
  3. Union bound (Boole’s inequality): P(A1∪⋯∪Ak)≤∑sP(As)P(A_1 \cup \cdots \cup A_k) \le \sum_s P(A_s), because the sum counts the overlaps of the events more than once. Subtracting a larger number gives “≥\ge”.
  4. Each interval is wrong with probability P(Vs∉Is)=αsP(V_s \notin I_s) = \alpha_s (at most αs\alpha_s when the CI is approximate).

Therefore, the overall confidence level is at least

100(1−∑s=1kαs)%.100\left(1 - \sum_{s=1}^k \alpha_s\right)\% .

E.g. three 95% CIs: overall at least 100(1−3×0.05)%=85%100(1 - 3 \times 0.05)\% = 85\% (compare 85.7% in the independent case). In the other direction, to get an overall level of at least 100(1−α)%100(1-\alpha)\%, choose the αs\alpha_s’s so that ∑sαs=α\sum_s \alpha_s = \alpha, e.g. αs=α/k\alpha_s = \alpha/k: for k=2k = 2 measures and overall 90%, make two 95% CIs; for k=5k = 5 and overall 90%, five 98% CIs. The price is that each individual CI is wider (a larger critical value tαs/2, n−1t_{\alpha_s/2,\,n-1}), so with many measures the individual CIs can become too wide to be useful.


6. Output Analysis
http://example.com/2026/09/08/2026-09-08-output-analysis/
Author
Wind_like
Posted on
September 8, 2026
Licensed under