Skip to content
Module 03 of 1265 min readAdvanced

Markowitz mean-variance optimisation

The 1952 paper. Setting up the QP. The efficient frontier in closed form. The two-fund theorem.

25%

Listen along

Read “Markowitz mean-variance optimisation” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Harry Markowitz's 1952 paper introduced the idea of choosing portfolios to minimise variance subject to a target return. It is the single most influential paper in modern finance — Markowitz won the 1990 Nobel for it — and the algebraic machinery he introduced is the same machinery a Goldman Sachs portfolio engineer uses on Friday afternoon today.

The setup

math
Variables: w ∈ R^n (portfolio weights)
Objective: minimise (1/2) wᵀΣw - λ μᵀw
Constraint: 1ᵀw = 1 (fully invested)

λ ≥ 0 is the risk-aversion parameter. λ = 0 gives the minimum-variance portfolio; λ → ∞ concentrates in the maximum-mean asset. Sweeping λ traces out the efficient frontier in (σ, μ) space.

Closed-form solution

Lagrangian: L = (1/2) wᵀΣw - λμᵀw - ν(1ᵀw - 1). FOC: Σw = λμ + ν1, so w = λΣ⁻¹μ + νΣ⁻¹1. Constraint 1ᵀw = 1 gives ν = (1 - λ · 1ᵀΣ⁻¹μ) / (1ᵀΣ⁻¹1). The frontier portfolio at risk-aversion λ:

math
w(λ) = Σ⁻¹[(1ᵀΣ⁻¹1) (λμ) - (1ᵀΣ⁻¹μ)(λ) · 1 + 1] / (1ᵀΣ⁻¹1)
Or, more cleanly:
A = 1ᵀΣ⁻¹1, B = 1ᵀΣ⁻¹μ, C = μᵀΣ⁻¹μ
w(λ) = (1/A) Σ⁻¹1 + λ Σ⁻¹(μ - (B/A) 1)

Two-fund theorem

Every efficient portfolio is a linear combination of two fixed efficient portfolios. Take w_MV (the minimum-variance portfolio, λ = 0) and any other efficient portfolio w_α (λ = α > 0); every other efficient portfolio is θ w_MV + (1 - θ) w_α for some θ. This is just the affine structure of the frontier in (μ, σ) space.

The efficient frontier

In (σ, μ) plane, the set of all (σ(w), μ(w)) over feasible w is a region bounded above and below by hyperbolic curves. The upper boundary is the efficient frontier — for each σ, the maximum achievable μ. Investors should hold only points on this frontier; everything else is dominated.

math
σ²(μ_target) = (A μ²_target - 2B μ_target + C) / (AC - B²)
(Hyperbola in (σ, μ) space)

Sensitivity to inputs

Markowitz portfolios are infamously unstable in their weights. Small changes in μ can swing weights from +30% to -30% in a single asset (Best-Grauer 1991, Michaud 1989). The reason is that the optimisation magnifies inverse-covariance times mean — and inverse covariances are noisy when Σ is high-dimensional or ill-conditioned.

Sources of instability

  • Mean estimates are very noisy (SE roughly σ/√T per asset).
  • Sample covariance is rank-deficient or ill-conditioned for n ≥ T.
  • Σ⁻¹ amplifies estimation noise.
  • Corner solutions: with no inequality constraints, optimisations often concentrate in 2-3 names.

Practical fixes

  • Add long-only constraint w ≥ 0 — eliminates the worst short positions but still concentrated.
  • Add maximum weight constraints (e.g., w_i ≤ 5%).
  • Use shrinkage covariance (Ledoit-Wolf) instead of sample.
  • Use robust mean estimates (James-Stein, equilibrium-implied, Black-Litterman).
  • Resample (Michaud-Bayesian): generate many bootstrapped efficient frontiers, average the weights.

The empirical embarrassment

Out-of-sample, raw Markowitz portfolios often UNDERPERFORM the equal-weighted (1/N) portfolio (DeMiguel-Garlappi-Uppal 2009). The reason: estimation error in μ dominates the optimal-portfolio gain. This is not a failure of theory; it's a failure of inputs. Modern practitioners (a) use stable mean inputs (BL, equilibrium), (b) constrain weights, (c) regularise Σ. With these fixes, Markowitz-based portfolios beat 1/N reliably.

Exercise

Three assets with μ = (8%, 10%, 12%) and Σ = diag(0.04, 0.09, 0.16). Risk-free rate r_f = 2%. (1) Compute A = 1ᵀΣ⁻¹1, B = 1ᵀΣ⁻¹μ, C = μᵀΣ⁻¹μ. (2) Find the minimum-variance portfolio weights. (3) Find the tangency portfolio (max Sharpe).

Loading progress…
LeadAfrikPublic Economics Hub