Expected Value

The expected value is the probability-weighted average of a random variable — the number a long run of draws settles around. In epidemiology the basic reproduction number R0R_0 is exactly such an expectation: the expected number of secondary infections produced by one case in a fully susceptible population, just as expected survival time is the mean time a patient lives. It anchors nearly every summary in statistics, from the mean of a distribution to the target of an estimator.

Definition

For a discrete random variable XX with probability mass function p(x)p(x), E[X]=xxp(x).\mathbb{E}[X] = \sum_x x\,p(x).

For a continuous random variable with density f(x)f(x), E[X]=xf(x)dx.\mathbb{E}[X] = \int_{-\infty}^{\infty} x\,f(x)\,dx.

The sum or integral must converge absolutely for the expectation to exist.

Interpretation as a long-run average

If you draw XX independently many times, the running average of those draws approaches E[X]\mathbb{E}[X]. This is not a metaphor — it is the law of large numbers, and it is why E[X]\mathbb{E}[X] is often called the “mean” of XX.

Linearity

Expectation is linear. For constants a,ba, b, E[aX+b]=aE[X]+b,\mathbb{E}[aX + b] = a\,\mathbb{E}[X] + b, and for any two random variables, E[X+Y]=E[X]+E[Y].\mathbb{E}[X + Y] = \mathbb{E}[X] + \mathbb{E}[Y]. The second identity holds even when XX and YY are dependent — a fact used constantly to compute means of sums.

Law of the unconscious statistician

To find the expected value of a function g(X)g(X) you do not need the distribution of g(X)g(X); you can weight gg by the distribution of XX: E[g(X)]=xg(x)p(x)org(x)f(x)dx.\mathbb{E}[g(X)] = \sum_x g(x)\,p(x) \quad\text{or}\quad \int g(x)\,f(x)\,dx.

Worked example

Fair die. With p(x)=1/6p(x) = 1/6 for x{1,,6}x \in \{1,\dots,6\}, E[X]=1+2+3+4+5+66=216=3.5.\mathbb{E}[X] = \frac{1+2+3+4+5+6}{6} = \frac{21}{6} = 3.5. The expected value need not be an attainable outcome.

Exponential. For XX with density f(x)=λeλxf(x) = \lambda e^{-\lambda x} on x0x \ge 0, E[X]=0xλeλxdx=1λ.\mathbb{E}[X] = \int_0^\infty x\,\lambda e^{-\lambda x}\,dx = \frac{1}{\lambda}. With rate λ=2\lambda = 2, the mean waiting time is 0.50.5.

Simulation

The sample average of many draws should land near E[X]\mathbb{E}[X].

R

set.seed(1)
die <- sample(1:6, size = 1e6, replace = TRUE)
mean(die)              # ~ 3.5

exp_draws <- rexp(1e6, rate = 2)
mean(exp_draws)        # ~ 0.5

Python

import numpy as np
np.random.seed(1)

die = np.random.randint(1, 7, size=1_000_000)
print(die.mean())            # ~ 3.5

exp_draws = np.random.exponential(scale=1/2, size=1_000_000)
print(exp_draws.mean())      # ~ 0.5
3.503028
0.5008809237171852

Julia

using Random, Statistics
Random.seed!(1)

die = rand(1:6, 1_000_000)
println(mean(die))           # ~ 3.5

exp_draws = randexp(1_000_000) ./ 2   # rate 2 => mean 0.5
println(mean(exp_draws))     # ~ 0.5

Why it matters for statistics

Expectation defines what an estimator is aiming at: an estimator is unbiased when its expected value equals the parameter. Linearity makes the mean of a sample average trivial to compute, and the law of the unconscious statistician gives variances, moments, and likelihoods without ever deriving a new distribution.