Effective sample size

Julia Fukuyama

Simulation-Based Inference · Lecture 18

How unstable are weighted averages?

Suppose:

  • We have independent observations \(Y_1, \ldots, Y_N\), each with variance \(\sigma^2\).
  • We have some fixed weights \(w_1\ldots, w_N\), satisfying \(w_i \ge 0\) and \(\sum_{i=1}^N w_i = 1\).

Then:

\[ \text{Var}(\sum_{i=1}^N w_i Y_i) = \sigma^2 \sum_{i=1}^N w_i^2. \]

Specialize to unweighted averages

If our weights satisfy \(w_i = 1/N\), the computation above tells us what the variance of the unweighted average of the \(Y_i\)’s is.

\[ \text{Var}(\sum_{i=1}^N w_i Y_i) = \sigma^2 \sum_{i=1}^N w_i^2 = \sigma^2 N /N^2 = \sigma^2 / N . \]

This gives the baseline: if we have equally weighted/unweighted samples, the variance of the mean is \(\sigma^2 / N\).

What number of unweighted samples would have variance equal to our weighted average?

  • \(M\) unweighted samples give a variance of \(\sigma^2 / M\).
  • Our \(N\) weighted samples give a variance of \(\sigma^2 \sum_{i=1}^N w_i^2\).

Equate and solve for \(M\):

\[ \sigma^2 / M = \sigma^2 \sum_{i=1}^N w_i^2 \\ M = 1 / \sum_{i=1}^N w_i^2 \]

So we call \(1/ \sum_{i=1}^N w_i^2\) the effective sample size.

Interpretation is that it is the number of equally weighted samples that would give you the same variance.

Notes

  • \(1 \le \text{ESS} \le N\). ESS equals \(N\) iff all weights are equal, and equals 1 iff one observation has weight 1 and the remainder has weight 0.
  • For importance sampling, if you’re being picky, the derivation doesn’t go through exactly because the weights a random, not fixed, but we still tend to use the same interpretation of the importance sampling weights.
  • The absolute ESS indicates whether you have “enough” samples to accurately estimate whatever posterior quantities you are interested in.
  • The ratio of ESS to \(N\) can help you diagnose how well your proposal matches your target: if there are regions where the target is high and the proposal is low, they’ll have really large weights when they get sampled and \(\text{ESS} / N\) will be small.
  • ESS can’t tell you that you completely missed a high-probability region.