← Moment Equations

02

Expectation and the sample mean

Expectation is the centre of a model distribution; the sample mean is its finite-simulation estimate.

Expectation is a probability-weighted average

If a discrete random variable \(X\) can take values \(x\) with probabilities \(\Pr(X=x)\), then

\[\mathbb E[X]=\sum_x x\,\Pr(X=x).\]

Expectation describes the long-run centre of repeated outcomes. It need not be an attainable individual outcome: an expected infectious count may be 18.4 although every CTMC realisation is an integer.

Sample mean estimates expectation

When the theoretical probabilities are unavailable, simulate \(M\) independent values \(X_1,\ldots,X_M\) and calculate

\[\overline X_M=\frac{1}{M}\sum_{r=1}^{M}X_r.\]

The expectation is a property of the model distribution. The sample mean is a random estimate computed from a finite sample.

Why independence matters

Each epidemic must use new random draws while keeping the same model and initial conditions. Copying one outcome many times does not provide more information about the distribution.

Interactive Python laboratory

Estimate \(\mathbb E[I(20)]\) from 5,000 independent SIS CTMC simulations and watch the running sample mean stabilise.

Interactive PythonExpectation and sample mean

Output

Run the code to see the result.

Interpretation

The running mean fluctuates strongly when only a few epidemics have been observed. It becomes more stable with more independent runs, but a finite sample mean is still an estimate. Lesson 04 will quantify Monte Carlo error.

What this lesson adds

You can now distinguish expectation from one outcome and from a finite sample mean, calculate a running mean, and explain why larger independent samples provide more stable estimates.