Contents
Deep Breakdown
What it tells me (Situation Awareness): The linearity of expectation: a linear transformation of a random variable shifts and scales the expected value in the same way. This is one of the most powerful properties of expectation — it holds even for dependent random variables, and it is the basis for computing expected values of sums without knowing the joint distribution.
Flowchart
Real-world use
Where it is used
Any time you transform a random variable linearly: scaling revenue by a commission rate, shifting scores by a baseline, computing expected portfolio returns as a weighted sum of expected individual returns.
Problem it solves
Lets you compute without recomputing the full distribution from scratch — just transform the mean directly.
How it solves the problem
From the definition: .
Example in a business
Revenue share model: agent earns of each deal. . If $E[\text{deal size}] = \$50{,}000$, agent expected earnings = $$10{,}000$.
The formula, piece by piece
- : scaling constant (multiplicative).
- : shift constant (additive).
- Extends to sums: regardless of dependence.
The formula in words
"The expected value of a linear transformation is times the expected value of , plus ."
Critical Concepts
- Holds for BOTH dependent and independent variables (unlike variance).
- Z-score transformation: since , : .
- Bias-variance tradeoff uses this: bias = .
- : sample mean is unbiased (by linearity).
Step-by-step calculation (tiny example)
Step 1: Known expectation Dice: .
Step 2: Linear transform Revenue from bet: (win double value, minus entry fee of 3).
Step 3: Apply linearity
Code examples
Beginner example (Python)
import numpy as np
from scipy.stats import binom
# Commission model: agent gets 20% of deal value, minus $500 overhead
n_deals = 10
p_close = 0.3
avg_deal_value = 5000
E_deals = n_deals * p_close # E[Binomial(10, 0.3)] = 3
a = avg_deal_value * 0.20 # commission rate
b = -500 # overhead cost
E_agent_revenue = a * E_deals + b
print(f"E[agent revenue] = ${E_agent_revenue:,.2f}") # $2,500Beginner example (R)
n_deals <- 10; p_close <- 0.3; avg_deal <- 5000
e_deals <- n_deals * p_close # E[Binom(10, 0.3)] = 3
e_revenue <- (avg_deal * 0.20) * e_deals + (-500)
cat(sprintf("E[agent revenue] = $%s\n", formatC(e_revenue, format = "f", digits = 2, big.mark = ",")))Professional example (Python)
import numpy as np
from scipy.stats import binom, norm
def portfolio_expected_return( asset_weights: np.ndarray, expected_returns: np.ndarray, risk_free_rate: float = 0.02 ) -> dict[str, float]:
"""Compute expected portfolio return using linearity of expectation.
E[portfolio] = sum_i(w_i * E[r_i]) = w^T * mu.
Uses linearity: no independence assumption needed.
Args:
asset_weights: w_i, portfolio weights (sum to 1).
expected_returns: E[r_i], expected return per asset.
risk_free_rate: Risk-free rate for excess return.
Returns:
Dict with portfolio expected return and excess return.
"""
if abs(asset_weights.sum() - 1.0) > 1e-6:
raise ValueError(f"Weights sum to {asset_weights.sum():.4f}, must equal 1")
expected_portfolio = float(np.dot(asset_weights, expected_returns))
excess_return = expected_portfolio - risk_free_rate
return {
"expected_return": expected_portfolio,
"excess_return": excess_return,
"sharpe_numerator": excess_return,
}
# 4-asset portfolio
weights = np.array([0.40, 0.30, 0.20, 0.10])
expected_returns = np.array([0.12, 0.08, 0.15, 0.05])
result = portfolio_expected_return(weights, expected_returns)
print(f"E[portfolio return] = {result['expected_return']*100:.2f}%")
print(f"Excess return = {result['excess_return']*100:.2f}%")
for idx, (w, r) in enumerate(zip(weights, expected_returns)):
print(f" Asset {idx+1}: weight={w:.0%}, E[r]={r:.0%}, contribution={w*r*100:.2f}%")Source: domain knowledge