AI Glossary / Mathematics and optimization / Advanced

Conditional expectation

Definition

Conditional expectation is the average value of a random quantity given specified information. For an integrable random variable Y and an information set represented by a sigma-algebra G, E[Y | G] is a random variable that uses only that information and preserves Y's averages over every event describable by it.

What it means

An unconditional expectation averages across all possibilities in a probability model. A conditional expectation updates that average after restricting attention to the information available.

For example, E[Y | X] is a function of the observed quantity X and is itself random before X is observed. After observing a particular value x, E[Y | X = x] gives the corresponding conditional mean, wherever that conditional description is appropriately defined.

How it works

For discrete X with P(X = x) greater than zero, calculate E[Y | X = x] by weighting each possible Y value by its conditional probability. For a continuous conditional distribution, the analogous calculation integrates y against that distribution.

The general definition avoids relying on events of positive point probability. It requires the conditional expectation to be measurable using the specified information and to have the same integral as Y on every event in that information set. For integrable Y, it is unique up to changes on events of probability zero.

When Y has a finite second moment, its conditional mean minimizes expected squared prediction error among predictions using that information. This optimality concerns a specified probability model and loss, not every business objective or every estimated prediction model.

Three practical examples

1. Demand prediction: estimate average demand given observable conditions such as day type and weather. The resulting mean can inform planning while uncertainty around it remains relevant.

2. Regression: under squared-error loss, the population prediction target is a conditional mean. A fitted model approximates that target using limited data and modeling assumptions.

3. Combining forecasts: average conditional forecasts across the probabilities of the conditions to recover the unconditional expectation. Weighting groups equally when they occur at different rates generally gives the wrong overall average.

Think of it this way

Imagine sorting possible outcomes into folders according to the information you have. Conditional expectation assigns an average to each folder. Opening a folder narrows what you know, but the outcomes inside can still vary.

Worked example

Consider an original demand model for a shop. A day is Rainy with probability 0.25 and Dry with probability 0.75. On a Rainy day, demand is either 100 or 140 units, each with conditional probability one-half. On a Dry day, it is either 40 or 80 units, again with equal conditional probabilities.

The conditional mean on Rainy days is (100 + 140)/2 = 120. On Dry days it is (40 + 80)/2 = 60. Neither forecast is a possible actual demand value in this simplified model. An expectation need not equal an attainable outcome.

Before the day type is known, the overall expectation is 0.25 × 120 + 0.75 × 60 = 75 units. Averaging 120 and 60 equally would give 90, incorrectly ignoring the more frequent Dry days.

Using a constant forecast of 75 gives expected squared error 0.125(100 − 75) squared + 0.125(140 − 75) squared + 0.375(40 − 75) squared + 0.375(80 − 75) squared = 1075 square units.

If the day type is available at prediction time, forecast 120 for Rainy and 60 for Dry. Every actual outcome is then 20 units from its conditional mean, so expected squared error becomes 400 square units. The improvement is 675, the variance of the two conditional means around 75.

Thus the total variance decomposes into 400 of average within-type variance plus 675 of between-type variance. Knowing the day type improves the ideal squared-error forecast but does not eliminate uncertainty.

This calculation assumes the condition is actually known. A weather forecast that can be wrong would require conditioning on that forecast and its relationship with the true day type, rather than pretending the future weather was already observed.

Illustrative case study

In a fictional service operation, analysts predict daily request volume using categories available before scheduling. A dashboard initially presents conditional means as firm staffing requirements, even though request volumes vary substantially within each category.

The team separates the mean forecast from a description of uncertainty and checks predictions on later days. It also finds one proposed input that becomes available only after the workday ends, so it removes that input from the advance-planning model.

The revised analysis distinguishes three issues: the theoretical conditional mean, the model's estimate of it and the decision made from that estimate.

Common misconceptions and mistakes

Conditional expectation is not conditional probability, although a probability can be written as the expectation of an indicator variable.

The conditional mean is not generally the median or mode. Different prediction losses can favor different summaries of the same distribution.

Conditioning is not intervention. Observing that demand differs with weather does not establish what would happen if another correlated variable were deliberately changed.

More information cannot worsen the minimum achievable population squared error, because a predictor can ignore it. In practice, an estimated model can perform worse through limited data, overfitting, errors or unavailable inputs.

Business use

Conditional means help translate observed context into average forecasts, comparisons and model targets. They are especially useful when the cost being evaluated is naturally connected to squared deviations.

Operational decisions may require more than an average. Unequal costs of underprediction and overprediction, capacity constraints and tail events can make other distributional summaries relevant. Document what information is available, what population the probabilities describe and how the estimated forecast is validated.

People also ask

Is E[Y | X] a number or a random variable?

Before observing X it is a random variable; evaluating its defining function at an observed x gives a conditional mean value.

Can the mean be an impossible outcome?

Yes. The example's conditional mean of 120 lies between its two possible Rainy-day outcomes.

Does averaging conditional expectations recover E[Y]?

Yes, under the appropriate integrability conditions; this is the law of total expectation.

Check your understanding

What is the Rainy-day conditional mean?

Answer: 120 units.

Why is the overall mean 75 rather than 90?

Answer: Rainy and Dry days have different probabilities, so their means require unequal weights.

What uncertainty remains after observing day type?

Answer: Demand still differs by 20 units from the conditional mean in this model.

Related terms

  • Conditional probability distribution
  • Mean Squared Error
  • Expectation
  • regression
  • law of total expectation
  • law of total variance
  • sigma-algebra

Learn next

Recalculate the example with unequal probabilities within each day type. Then compare a conditional mean with a conditional median and identify which loss function makes each an appropriate prediction target.

  • Loss function

More in Mathematics and optimization

  • Absolute error loss - Absolute error loss measures a numerical prediction's error as the absolute difference between its predicted and reference values: L(y,y-hat)=|y-y-hat|.
  • Active-set method - An active-set method is an optimization approach that works with a changing subset of constraints believed to be tight at the solution.
  • Adjoint state method - The adjoint state method computes how a chosen objective changes when the parameters of a mathematical model change.
  • Σ-algebra
  • Algebraic connectivity - Algebraic connectivity is the second-smallest eigenvalue of a graph's Laplacian matrix.
  • Algorithm IMED - Algorithm IMED, short for Indexed Minimum Empirical Divergence, is a method for choosing actions in a stochastic multi-armed bandit problem.

Sources

Aalto Dictionary of Machine Learning, conditional expectation entry and related probability definitions: https://aaltodictionaryofml.github.io/ADictML_Main.pdf

The demand calculations and service-operation case are original illustrations.

Previous: Conditional entropy Next: Conditional Gaussian

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer