Linearity of expectation
The expected value of a sum is the sum of the expected values. This holds whether or not the pieces are independent.
01The formula
- any random quantities, for example the rolls of n dice or the P&L of n positions
- expected value
- fixed numbers: a scale and a shift
02See it move
03Where it is used
- Portfolio managerGets the expected return of a portfolio as the weighted sum of the assets' expected returns, with no need for correlations.
- Execution traderAdds the expected cost of each child order to get the expected cost of the whole parent order.
- Quant researcherSolves counting puzzles quickly by writing a total as a sum of simple 0-or-1 indicators and adding their chances.
04Why traders use it
It is the one rule about averages you can use without knowing how things depend on each other. Expected P&L adds across trades and positions; risk does not.
05Worked example
Roll 3 dice with 6 faces. One die averages 3.50, so the sum averages 10.50. Computing the mean directly from the full distribution of the sum gives the same 10.50.
06How it is built
- For two discrete variables, .
- Split the sum: .
- Summing the joint chance over leaves , so the first part is ; likewise the second is .
- No step used independence, so it holds for any and . Repeat for terms.
07The common mistake
Extending it to variance or to products. and need independence or zero correlation; linearity of expectation does not.
08In Python and LaTeX
import numpy as np
n, f = 3, 6
dist = np.array([1.0])
for _ in range(n):
dist = np.convolve(dist, np.ones(f) / f)
sums = np.arange(n, n * f + 1)
print('mean of the sum:', round((sums * dist).sum(), 4), ' n*E[die]:', n * (f + 1) / 2) # 10.5E[X_1 + X_2 + \dots + X_n] = E[X_1] + E[X_2] + \dots + E[X_n], \qquad E[aX + b] = a\,E[X] + b
09Where it fits
Rather not code the maths yourself? Describe your trading idea and let AI build the bot.
Build a bot with AgenKitThe worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.