Expected Value: Formula and Examples
Expected value is the weighted average of all possible outcomes of a random variable, where the weights are the probabilities of each outcome. If you could repeat an experiment infinitely many times,...
Key Insights
- Expected value represents the long-run average outcome of a random variable, calculated by multiplying each possible outcome by its probability and summing the results
- While essential for rational decision-making, expected value alone ignores risk and variance—a $100 guaranteed payout differs significantly from a 10% chance at $1,000 even though both have the same expected value
- The linearity property E(aX + b) = aE(X) + b makes expected value calculations tractable for complex scenarios involving multiple random variables
Introduction to Expected Value
Expected value is the weighted average of all possible outcomes of a random variable, where the weights are the probabilities of each outcome. If you could repeat an experiment infinitely many times, the expected value is what you’d average out to per trial.
This concept underpins rational decision-making across domains. Casinos use expected value to ensure the house always wins in the long run. Investors calculate expected returns to compare investment opportunities. Insurance companies price premiums based on expected claim payouts. Understanding expected value separates intuitive guesses from quantitative analysis.
The power of expected value lies in its simplicity: it reduces complex probabilistic scenarios to a single number that represents the “center” of a distribution. However, as we’ll see, this simplicity can also be misleading when used without considering other factors like variance and risk tolerance.
The Expected Value Formula
For a discrete random variable X that can take values x₁, x₂, …, xₙ with probabilities P(x₁), P(x₂), …, P(xₙ), the expected value is:
E(X) = Σ(xᵢ × P(xᵢ))
Each outcome is multiplied by its probability, then all products are summed. The probabilities must sum to 1.
For continuous random variables, the sum becomes an integral: E(X) = ∫ x × f(x) dx, where f(x) is the probability density function. We’ll focus on the discrete case since it’s more common in practical applications.
Here’s a simple Python implementation:
def expected_value(outcomes, probabilities):
"""
Calculate expected value from outcomes and probabilities.
Args:
outcomes: List of possible outcomes
probabilities: List of corresponding probabilities
Returns:
Expected value as a float
"""
if len(outcomes) != len(probabilities):
raise ValueError("Outcomes and probabilities must have same length")
if not abs(sum(probabilities) - 1.0) < 1e-10:
raise ValueError("Probabilities must sum to 1")
return sum(x * p for x, p in zip(outcomes, probabilities))
# Example usage
outcomes = [1, 2, 3, 4, 5, 6]
probabilities = [1/6] * 6
ev = expected_value(outcomes, probabilities)
print(f"Expected value of a fair die: {ev}") # 3.5
Basic Examples
Dice Roll
A fair six-sided die has outcomes {1, 2, 3, 4, 5, 6}, each with probability 1/6:
E(X) = 1×(1/6) + 2×(1/6) + 3×(1/6) + 4×(1/6) + 5×(1/6) + 6×(1/6) = 21/6 = 3.5
Notice the expected value (3.5) isn’t even a possible outcome. Expected value represents the long-run average, not the most likely result.
Betting Game
Consider a game where you pay $10 to play. You roll a die: if you get a 6, you win $50; otherwise, you win nothing.
def betting_game_ev():
"""Calculate expected value of betting game."""
cost = -10
outcomes = [50 - 10, 0 - 10] # Net profit/loss
probabilities = [1/6, 5/6]
ev = expected_value(outcomes, probabilities)
return ev
ev = betting_game_ev()
print(f"Expected value: ${ev:.2f}") # Expected value: $-3.33
The negative expected value means you lose $3.33 on average per game. Playing repeatedly guarantees losses.
Monte Carlo Verification
We can verify theoretical expected values through simulation:
import random
import numpy as np
def simulate_dice_rolls(n_rolls=100000):
"""Simulate dice rolls and calculate empirical expected value."""
rolls = [random.randint(1, 6) for _ in range(n_rolls)]
return np.mean(rolls)
def simulate_betting_game(n_games=100000):
"""Simulate betting game and calculate empirical expected value."""
results = []
for _ in range(n_games):
roll = random.randint(1, 6)
if roll == 6:
results.append(50 - 10)
else:
results.append(0 - 10)
return np.mean(results)
print(f"Simulated die EV: {simulate_dice_rolls():.2f}") # ~3.50
print(f"Simulated game EV: ${simulate_betting_game():.2f}") # ~-3.33
As the number of trials increases, the empirical average converges to the theoretical expected value—this is the Law of Large Numbers.
Properties of Expected Value
Linearity
Expected value is linear, meaning:
E(aX + b) = aE(X) + b
If you multiply a random variable by a constant and add another constant, the expected value transforms the same way.
def demonstrate_linearity():
"""Show linearity property of expected value."""
# Original random variable: die roll
outcomes = [1, 2, 3, 4, 5, 6]
probs = [1/6] * 6
ev_x = expected_value(outcomes, probs)
print(f"E(X) = {ev_x}")
# Transform: Y = 3X + 5
a, b = 3, 5
transformed_outcomes = [a * x + b for x in outcomes]
ev_y = expected_value(transformed_outcomes, probs)
# Should equal a*E(X) + b
expected_ev_y = a * ev_x + b
print(f"E(3X + 5) = {ev_y}")
print(f"3*E(X) + 5 = {expected_ev_y}")
print(f"Match: {abs(ev_y - expected_ev_y) < 1e-10}")
demonstrate_linearity()
Expected Value of Sums
For any two random variables X and Y (even if dependent):
E(X + Y) = E(X) + E(Y)
This additivity property is incredibly useful. You can decompose complex problems into simpler components, calculate expected values separately, then sum them.
Practical Applications
Investment Portfolio Expected Return
Calculate the expected return of a portfolio by weighting each asset’s expected return by its allocation:
def portfolio_expected_return(assets, returns, probabilities):
"""
Calculate portfolio expected return.
Args:
assets: Dict mapping asset names to allocation percentages
returns: Dict mapping asset names to possible return scenarios
probabilities: Dict mapping asset names to scenario probabilities
Returns:
Expected portfolio return
"""
portfolio_ev = 0
for asset, allocation in assets.items():
asset_ev = expected_value(returns[asset], probabilities[asset])
portfolio_ev += allocation * asset_ev
return portfolio_ev
# Example portfolio
assets = {
'stocks': 0.6,
'bonds': 0.3,
'cash': 0.1
}
returns = {
'stocks': [0.15, 0.08, -0.05],
'bonds': [0.05, 0.03, 0.01],
'cash': [0.02, 0.02, 0.02]
}
probabilities = {
'stocks': [0.4, 0.4, 0.2],
'bonds': [0.4, 0.4, 0.2],
'cash': [1.0, 0.0, 0.0] # Cash is deterministic
}
portfolio_return = portfolio_expected_return(assets, returns, probabilities)
print(f"Expected portfolio return: {portfolio_return*100:.2f}%")
A/B Testing Decision Framework
Use expected value to decide between variants when you have conversion rates and customer lifetime values:
def ab_test_expected_value(conversion_rate, avg_value, cost_per_visitor):
"""
Calculate expected value per visitor for an A/B test variant.
Args:
conversion_rate: Probability a visitor converts
avg_value: Average value of a conversion
cost_per_visitor: Cost to acquire each visitor
Returns:
Expected value per visitor
"""
outcomes = [avg_value - cost_per_visitor, -cost_per_visitor]
probabilities = [conversion_rate, 1 - conversion_rate]
return expected_value(outcomes, probabilities)
# Compare two variants
variant_a_ev = ab_test_expected_value(0.02, 500, 5)
variant_b_ev = ab_test_expected_value(0.025, 450, 5)
print(f"Variant A EV: ${variant_a_ev:.2f}")
print(f"Variant B EV: ${variant_b_ev:.2f}")
print(f"Choose: {'B' if variant_b_ev > variant_a_ev else 'A'}")
Common Pitfalls and Limitations
Expected Value vs. Most Likely Outcome
The expected value of a die roll is 3.5, but you’ll never roll 3.5. The mode (most likely outcome) and expected value are different concepts. Don’t confuse the long-run average with what typically happens in a single trial.
Ignoring Variance and Risk
Two scenarios can have identical expected values but vastly different risk profiles:
- Scenario A: Guaranteed $100
- Scenario B: 50% chance of $0, 50% chance of $200
Both have E(X) = $100, but most people prefer Scenario A due to risk aversion. Expected value ignores variance. For decision-making under uncertainty, also consider standard deviation and your risk tolerance.
St. Petersburg Paradox
Consider a game where you flip a coin repeatedly until it lands tails. If tails appears on flip n, you win $2ⁿ. The expected value is:
E(X) = Σ(2ⁿ × (1/2)ⁿ) = Σ(1) = ∞
The expected value is infinite, yet no rational person would pay an arbitrarily large amount to play this game. This paradox reveals that expected value alone doesn’t capture utility—people’s subjective value of money is non-linear.
When Expected Value Isn’t Enough
Expected value is most useful when:
- You can repeat the decision many times
- Outcomes won’t ruin you financially
- Variance is acceptable
For one-time decisions with catastrophic downside risk (like Russian roulette with positive expected value), you need additional frameworks like expected utility theory.
Conclusion
Expected value is the foundation of quantitative decision-making under uncertainty. The formula E(X) = Σ(xᵢ × P(xᵢ)) is simple, but its applications span gambling, investing, business strategy, and scientific research.
Use expected value when comparing alternatives with probabilistic outcomes. The linearity properties make complex calculations tractable. Always verify that probabilities sum to 1, and consider using Monte Carlo simulations to validate theoretical results.
However, remember the limitations. Expected value ignores risk and variance. It assumes you can repeat decisions many times. It doesn’t account for non-linear utility or catastrophic outcomes. For robust decision-making, combine expected value with variance analysis, risk assessment, and consideration of worst-case scenarios.
Master expected value, but know when to look beyond it. The best decisions integrate multiple statistical measures with domain expertise and risk tolerance.