Home / Maths for AI / Symbols / Probability and statistics

Expected value

Say it: "the expectation of X", "E of X"

What it means

The long-run average of a random variable: E[X]=∑xx P(X=x)\mathbb{E}[X] = \sum_x x\,P(X = x) (an integral for continuous variables).

Example

E[die]=1+2+3+4+5+66=3.5\mathbb{E}[\text{die}] = \tfrac{1 + 2 + 3 + 4 + 5 + 6}{6} = 3.5

You never roll 3.5, but that is the average.

In code

import numpy as np
rolls = np.random.default_rng(0).integers(1, 7, 100000)
print(round(rolls.mean(), 2))

Output

3.5

Where it appears in machine learning

The loss we really want to minimise is an expectation over all possible data, E[L]\mathbb{E}[L], estimated by an average over the training set.

Related symbols

Learn it properly in the free lesson Probability & Distributions, with practice questions that check your answers.