Learn
Lesson · Simulation and Variance Reduction · Running a system

Warm-Up and the Initial Transient

A run that begins with an empty system spends its first slots somewhere the steady state is not, and every average taken from slot zero carries that as a bias — a wrongness in the expectation, which no number of replications removes. Carrying the whole distribution forward one slot at a time makes the bias exact rather than anecdotal, and a longer run only dilutes it while discarding a warm-up removes it.

E[N₀], E[N₁], … = 0, 2/5, 3/5, 37/50, 17/20, … climbing toward 12/5 expected average over slots 0 to 399 2.2443 (exact, to 4 places) expected average over slots 100 to 399 2.3717 (exact, to 4 places) stationary mean 12/5 = 2.4 bias is in the EXPECTATION: replications shrink the variance and not this a longer run dilutes the transient; discarding it deletes the transient
The transient as theory, and the two averages it separates

Core ideas

What this lesson establishes

Three ideas. The first is the distinction the whole page turns on, the second makes it computable, and the third is the fix that is usually reached for and is the wrong one.

1

Bias and variance are different problems with different cures

Variance is how much the estimate moves when you reseed, and replications shrink it. Bias is where the estimate is aimed, and replications do nothing to it whatever: a thousand runs all started empty give a thousand estimates of the same wrong number, with a beautifully small standard error around it.

2

The transient is computable, not just visible

Starting from an empty system, the distribution of the number in system at slot t can be carried forward exactly, one slot at a time. For this queue the expected occupancy runs 0, 2/5, 3/5, 37/50, 17/20, … toward the stationary 12/5, and those are fractions rather than measurements. The bias is then a statement about numbers you can print.

3

Diluting a fixed error is much slower than deleting it

The transient is a fixed quantity of wrongness at the front of the run, so its share of the average falls like 1/T. Quadrupling the run length from 100 slots to 400 divides the remaining bias by about 3.5; throwing away the first quarter of the four-hundred-slot run divides it by about 5.5. Deleting wins, and it wins on a quarter of the compute.

The material

Where a run starts, and what that costs its average

Why the beginning of a run is not a sample of the thing being estimated, how much that is worth in numbers, and what actually removes it.

Definition · Initial transient

The initial transient is the part of a run during which the state distribution is still visibly moving away from the initial condition and toward the steady-state distribution. It is not a period of “noise”: the process is behaving correctly throughout, and it is simply not yet behaving like the system the long-run average describes.

Definition · Bias of an estimator

An estimator T of a quantity θ has bias E[T] − θ. Bias is a property of the estimator, not of a run: it does not shrink with replications, it does not show up in a standard error, and an interval built on that standard error is centred in the wrong place.

That is the whole reason this page exists. Every technique after it attacks variance, and all of them are worthless on an estimator aimed at the wrong number. A narrow interval around a biased estimate is worse than a wide one, because it is more convincing.

The transient, as arithmetic

The number in system at the end of a slot is a Markov chain: from state n a departure happens first with probability q, then an arrival with probability p, so the chain steps to n − 1, n or n + 1, and from 0 only to 0 or 1. Starting from the point mass at zero and pushing the whole distribution forward one slot at a time gives E[Nₜ] exactly, for every t.

p = 2/5, q = 1/2, started empty E[N₀] = 0 E[N₁] = 2/5 E[N₂] = 3/5 E[N₃] = 37/50 E[N₄] = 17/20 … E[N₅₀] ≈ 2.0332 E[N₁₀₀] ≈ 2.2633 E[N₃₉₉] ≈ 2.3982 stationary 12/5 = 2.4 expected time average over slots 0 to 399: 2.2443 expected time average over slots 100 to 399: 2.3717

Both of those averages are exact fractions shown to four places, not rounded numbers — they are averages of finitely many rationals. The bias of the naive estimator is 2.2443 − 2.4, about −0.1557; the bias after discarding a hundred slots is about −0.0283. The discard removes roughly four fifths of what was there, and it does so in theory, before any run has been made.

Theorem · A longer run dilutes; a discard deletes

Let B be the total excess or shortfall contributed by the transient. Averaging over T slots contributes B/T to the estimate, which falls like 1/T. Averaging over slots w to T instead removes the part of B that lay before w outright. Lengthening the run is therefore a 1/T effect and discarding is not.

The numbers say the same thing. At 100 slots the expected average is 1.8624, a shortfall of 0.5376; at 400 slots it is 2.2443, a shortfall of 0.1557. Four times the run divided the remaining bias by about 3.5. Discarding the first hundred of those four hundred slots takes the shortfall to 0.0283 — a further factor of about 5.5, bought with a quarter of the data rather than with four times the compute.

One run, and what it actually did

Example · Four hundred slots at seed 0

The average over every slot is 169/80 = 2.1125; the average over the three hundred slots after a warm-up of one hundred is 361/150 ≈ 2.4067. The discard moved the estimate up by about 0.2942, which is the direction the theory says and rather more than the theory's 0.1274 — because one run is an observation of the expectation and not the expectation.

Reseed and the sign can change. The same settings at seed 1 give 1.3075 from slot zero and 1.2367 after the discard: the discard moved the estimate down, on a run that spent its whole length below the steady state. That is not a counterexample to the bias; it is what a single observation of a quantity with a standard error looks like, and it is exactly why the exact transient is printed beside the run rather than the run being left to make the argument.

Batch means: replications out of one run

Definition · Batch means

Discard the warm-up, split what remains into b equal batches, and take the mean of each. A batch mean is far closer to independent of its neighbour than one slot is of the next, so the b batch means can be treated as replications: their average is the estimate and their sample variance is what an interval is built from.

On the run at seed 0 the four batches of seventy-five slots give means 34/25, 116/75, 19/25 and 149/25 — that is 1.36, 1.55, 0.76 and 5.96. Their average is 361/150, within 0.007 of the exact 12/5, and their sample variance is 10733/1875 ≈ 5.72. The point estimate could hardly be better and the four numbers behind it say the run has established almost nothing. Printing the second fact beside the first is the whole job.

That spread is also a warning about the batches themselves. A batch mean is only nearly independent of its neighbour if the batch is long compared with how fast the system forgets its state, and seventy-five slots of a queue running at 4/5 utilisation is not obviously long enough. The remedy is fewer, longer batches, and the diagnostic is to watch the batch variance as the batch count falls.

Interactive

Warm-up and the initial transient

Every average taken from an empty start is biased, and a longer run only dilutes it

A run that starts empty is not sampling the steady statethe transient shaded, the exact expectation drawn over the trace, and the two averages
the number in systemthe exact expectation at each slotthe warm-up discardedthe stationary mean

Method

Getting the beginning out of the answer

Five steps, and the fourth one is the check that most warm-up procedures skip.

1

Decide what the initial condition is, and admit that it is one

An empty system is a choice, not a neutral default, and it is the choice that biases a queueing average downward. Starting in a typical state, if you have one, is a legitimate alternative and it moves the bias rather than removing it.

2

Plot the quantity against time and look for the shape

Not for the noise — for the drift. A trace that climbs for two hundred slots and then wanders is showing you a transient and then a steady state, and the elbow is roughly where the warm-up should end.

3

Discard, and say how much you discarded

“The first hundred of four hundred slots” is a reportable procedure. A discard chosen after seeing which choice gave the nicest answer is a procedure that will not survive a second seed, and it is not honest to report only its output.

4

Check that the estimate has stopped moving as the warm-up grows

Increase the discard and watch the kept average. If it is still drifting, the warm-up is too short. If it has settled but the variance is climbing, you are throwing away data you needed, and the fix is a longer run rather than a longer discard.

5

Build the interval from batch means, not from slots

Consecutive slots of a queue are strongly dependent, so the sample variance over slots understates the spread badly. Batch means are the standard repair and they come with their own condition: the batches must be long enough for their means to be nearly independent.

Bias, dilution and batches

Score 0 / 0

Four hundred slots, a hundred discarded, four batches

The panel's opening state: p = 2/5, q = 1/2, four hundred slots, a warm-up of one hundred, four batches, seed 0. The exact column is computed from the chain and does not depend on the seed at all.

exact, from the chain started empty E[N₀..N₄] 0, 2/5, 3/5, 37/50, 17/20 stationary 12/5 = 2.4 E[average over slots 0..399] 2.2443 shortfall 0.1557 E[average over slots 100..399] 2.3717 shortfall 0.0283 this run, seed 0 average from slot 0 169/80 = 2.1125 average after the warm-up 361/150 ≈ 2.4067 the discard moved it up by 0.2942 batch means, four batches of 75 slots each slots 100..174 34/25 = 1.36 slots 175..249 116/75 ≈ 1.5467 slots 250..324 19/25 = 0.76 slots 325..399 149/25 = 5.96 mean of the four 361/150 ≈ 2.4067 their variance 10733/1875 ≈ 5.72 the estimate is 0.007 from the exact 12/5 and the four numbers behind it range from 0.76 to 5.96

The two exact averages are the spine of the page. 2.2443 and 2.3717 are what the estimator is aimed at with and without the discard, and both are exact fractions shown to four places. Against the stationary 2.4 they say the naive estimator is short by about 0.16 in expectation and the discarded one by about 0.03, before a single seed has been chosen.

The run then does its own thing, as runs do. It moved by 0.2942 where the theory says 0.1274, and at seed 1 it moves the other way entirely. Neither observation argues against the theory and neither confirms it; what confirms it is that the exact column does not move when the seed does.

For a faded rehearsal, drag the warm-up from 100 to 0 and then to 200. The supplied first move is that at a warm-up of zero the two averages are the same number by definition and the exact expected average reads 2.2443. Say what you expect the exact figure to be at a warm-up of 200, whether it can ever exceed 12/5, and what happens to the batch variance when only two hundred slots are left to split four ways.

Common mistakes

1
Averaging from slot zero because that is where the run startsIt is the default in every implementation and it is wrong for every queueing average. On the measured chain the naive estimator is aimed at 2.2443 where the answer is 2.4, and no care about the generator, the sampler or the number of replications touches that gap by a single digit.
2
Fixing the bias by running longerIt works, in the sense that 1/T tends to zero, and it is the expensive way round. Four times the run length bought a factor of about 3.5 on the remaining bias here; a quarter of that run thrown away bought a factor of about 5.5. Doing both is better than either, and doing only the first is the common choice because it needs no decision.
3
Building an interval from the slots of one runConsecutive slots of a busy queue are strongly dependent, so the sample variance over four hundred slots is far smaller than the variance of the average it is supposed to describe, and the resulting interval is confidently narrow and wrong. Batch means are the repair, and they are only a repair if the batches are long enough to have nearly forgotten each other.

Check your understanding

✓
Finish when an average taken from slot zero reads as a biased estimator rather than as the obvious one.

You should be able to say what distinguishes bias from variance and which techniques touch which, read the exact expected occupancy of a chain started empty and turn it into the expected average over a window, compare a longer run against a discard on the numbers rather than by intuition, form batch means from one run and state the condition under which they may be treated as replications, and say why a single run moving the wrong way is not evidence against any of it.

Note: Bias is dealt with. Everything after this page attacks the other half of the problem — the width — and all four techniques do it the same way, by moving a covariance rather than by buying draws. “Common Random Numbers” takes the first and simplest of them: feed two systems the same stream, and read what happens to the variance of their difference.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.