Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Find the Expected Value of a Random Variable

The expected value is the long-run average of a random variable. You get it by weighting each possible value by its probability and adding the results; for a continuous variable the sum becomes an integral.

Recognize the task

The question asks for a mean, an average outcome, a fair price, or a long-run gain: "how much do you expect to win?", "average number of defects", E[X]E[X] or μ\mu. Typical inputs: a table of values and probabilities, a formula p(x)p(x), a density f(x)f(x) on an interval. Test: can you list (or integrate over) every value with its probability? Then compute the weighted average.
Expected value is defined in the expected value lesson.

Ways to do it

Weighted sum over a pmfdiscrete
E[X]=∑xx p(x)E[X] = \sum_x x \, p(x)
For a table or a discrete formula: multiply each value by its probability and add.
Integral over a pdfcontinuous
E[X]=∫−∞∞x f(x) dxE[X] = \int_{-\infty}^{\infty} x \, f(x) \, dx
For a density, integrate x times the density over the support.
Formula of a named distributionshortcut
X∼Bin(n,p)  ⇒  E[X]=npX \sim \text{Bin}(n, p) \;\Rightarrow\; E[X] = np
When XX follows a known distribution, use its mean formula directly.

Steps

StepOn X∈{0,1,2,3}X \in \{0, 1, 2, 3\} with probabilities 0.1, 0.3, 0.4, 0.20.1,\ 0.3,\ 0.4,\ 0.2
1List every value with its probability. Use a table, the pmf formula, or the density and its support.xx: 0,1,2,30, 1, 2, 3; p(x)p(x): 0.1,0.3,0.4,0.20.1, 0.3, 0.4, 0.2
2Check that the probabilities add to 1. A missing value or a typo shows up here (normalization). For a density, check that it integrates to 11.0.1+0.3+0.4+0.2=10.1 + 0.3 + 0.4 + 0.2 = 1 ✓
3Multiply each value by its probability and add. For a density, integrate xf(x)x f(x) over the support instead.0+0.3+0.8+0.6=1.70 + 0.3 + 0.8 + 0.6 = 1.7
4Check that the answer is plausible. The mean lies between the smallest and largest value, closer to the values with more weight. It need not be a possible value.E[X]=1.7E[X] = 1.7, between 00 and 33 ✓

Worked examples

Example 1 · a fair die

equally likely
p(x)=16p(x) = \frac{1}{6} for x=1,…,6x = 1, \dots, 6
six equal weights
E[X]=1+2+3+4+5+66=216E[X] = \frac{1 + 2 + 3 + 4 + 5 + 6}{6} = \frac{21}{6}
weighted sum
E[X]=3.5E[X] = 3.5
not a face, still the mean

Example 2 · a game with a gain and a loss

fair price
X=10X = 10 with P=14P = \frac{1}{4}, X=−2X = -2 with P=34P = \frac{3}{4}
win 10 dollars or lose 2
E[X]=10⋅14+(−2)⋅34=104−64E[X] = 10 \cdot \frac{1}{4} + (-2) \cdot \frac{3}{4} = \frac{10}{4} - \frac{6}{4}
losses enter with a minus sign
E[X]=1E[X] = 1
average gain of 1 dollar per play

Example 3 · a density on an interval

continuous
f(x)=2xf(x) = 2x on [0,1][0, 1]
∫012x dx=1\int_0^1 2x \, dx = 1 ✓
E[X]=∫01x⋅2x dx=∫012x2 dxE[X] = \int_0^1 x \cdot 2x \, dx = \int_0^1 2x^2 \, dx
integrate xf(x)x f(x)
E[X]=[2x33]01=23E[X] = \left[\frac{2x^3}{3}\right]_0^1 = \frac{2}{3}
power rule, then evaluate
Check a table of your own in the expected value calculator.

See it happen

Put a weight p(x)p(x) at each position xx on a number line: the expected value is the point where the line balances. Heavy weights pull the balance point toward them, which is why the mean of 0,1,2,30, 1, 2, 3 with weights 0.1,0.3,0.4,0.20.1, 0.3, 0.4, 0.2 sits at 1.71.7, right of the middle. Drag the weights yourself in the discrete expected value visualizer.

Common mistakes

Averaging the values without their weights

✗ E[X]=0+1+2+34=1.5E[X] = \frac{0 + 1 + 2 + 3}{4} = 1.5
✓ weight by probability: 0.3+0.8+0.6=1.70.3 + 0.8 + 0.6 = 1.7
The plain average is correct only when all values are equally likely.

Probabilities that do not add to 1

✗ using 0.1,0.3,0.40.1, 0.3, 0.4 and forgetting P(X=3)=0.2P(X = 3) = 0.2
✓ list the full support first, then check the sum is 11

Integrating the density instead of x times the density

✗ E[X]=∫012x dx=1E[X] = \int_0^1 2x \, dx = 1
✓ E[X]=∫01x⋅2x dx=23E[X] = \int_0^1 x \cdot 2x \, dx = \frac{2}{3}

Pushing the expectation inside a square

✗ E[X2]=(E[X])2=2.89E[X^2] = (E[X])^2 = 2.89
✓ E[X2]=∑x2p(x)=0.3+1.6+1.8=3.7E[X^2] = \sum x^2 p(x) = 0.3 + 1.6 + 1.8 = 3.7
Average the squared values (expectation of a function).