Expectation

Expectation is an average under a probability distribution. Many objectives and evaluation metrics are expectations.

For a discrete random variable:

For a continuous random variable:

Empirical averages approximate expectations from finite data:

Expected risk is the population version of a supervised loss:

Empirical risk replaces the unknown distribution with a dataset:

The gap between and is why sampling, splits, confidence intervals, and distribution shift matter.

Linearity

Expectation is linear:

This holds even when and are not independent. Many loss decompositions and metric averages use this property.

Conditional Expectation

Conditional expectation averages under a conditional distribution:

For regression with squared error, the optimal prediction is the conditional mean:

This explains why different losses imply different target summaries.

Weighted Expectations

Sampling or class weighting changes the expectation:

If is the training sampler and deployment follows , the metric should make clear which expectation is being estimated.

Why It Matters

  • Training objectives average losses over data.
  • Evaluation estimates risk over a held-out distribution.
  • Sampling changes which expectation the model optimizes.
  • Monte Carlo estimates approximate intractable integrals.
  • Reinforcement learning, generative modeling, and evaluation all differ mainly in which distribution the expectation is taken under.

Checks

  • Which distribution is the expectation under?
  • Is the estimate biased by sampling, filtering, or missing data?
  • Is the average over examples, tokens, classes, tasks, seeds, or folds?
  • Does the reported metric include uncertainty or variance?
  • Is the empirical average weighted by the sampling process?
  • Are macro, micro, per-class, per-token, and per-example averages being mixed?
  • Does the loss target a mean, median, mode, quantile, ranking, or calibrated probability?
  • Is the expectation over data, model samples, seeds, folds, or annotators?