The Claude Quant PlaybookDownload ebookDownload ebook

Linearity of expectation

intermediateProbability6 of 12

The expected value of a sum is the sum of the expected values. This holds whether or not the pieces are independent.

Build a trading system with Claude.Download ebook

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

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

  1. For two discrete variables, .
  2. Split the sum: .
  3. Summing the joint chance over leaves , so the first part is ; likewise the second is .
  4. 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.5
E[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 AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.