Mean-variance optimisation treats its inputs as truth, but expected returns and covariances are estimates with enormous error bars — and the optimiser loads hardest on exactly the assets whose estimates are most wrong in your favour. It is an error maximiser. Every practical fix — shrinkage, equal weight, risk parity — is a way of telling the optimiser less, so it has less noise to amplify.
The idea
Here is an experiment to run in your framework tonight, because nothing I write will be as convincing as watching it happen. Take five liquid assets, estimate their mean returns and covariance from the last five years of daily data, and feed both into a textbook mean-variance optimiser. Look at the weights. Now re-estimate using a window shifted by six months — a change that alters the mean estimates by fractions of a percent — and optimise again. The weights don't wobble. They lurch: an asset at +40% goes to −20%, a short flips long. Two statistically indistinguishable descriptions of the world, two wildly different portfolios.
Markowitz's 1952 framework is genuinely beautiful, and nothing in this lesson says otherwise: given the true means and the true covariance , the optimal weights follow mechanically. The catch is the word "given". You don't have ; you have , a noisy estimate, and the noise is not a small correction — for expected returns it is usually larger than the signal. A stock with a true annual risk premium of 5% and volatility of 20% needs, by the standard-error arithmetic of lesson 2.6, on the order of sixty years of data before the estimate's confidence interval excludes zero. You are feeding the optimiser numbers that are mostly noise and asking it to take maximal advantage of their differences.
And taking maximal advantage of differences is precisely what the optimiser does — that's its job. Michaud (Michaud 1989) gave the behaviour its enduring name: mean-variance is an error maximiser. Think about why from the optimiser's point of view. It scans the estimates for the asset with the highest return per unit of risk and correlation, and concentrates weight there. But which asset looks best in a noisy sample? With high probability, one whose return was overestimated and whose risk was underestimated — the asset where the estimation error happens to be most flattering. The optimiser cannot tell luck from skill in your inputs, so it systematically buys your data's flattery and shorts its pessimism. The out-of-sample performance of naive mean-variance is poor for exactly this reason: the portfolio was custom-built around errors.
The failure has a hierarchy worth internalising. Errors in means hurt most. Small changes in produce violent weight changes, and means are the hardest input to estimate. Covariance errors hurt less but still bite, especially when you have many assets and short histories — with assets you're estimating covariance entries, and once approaches the number of observations the sample covariance matrix becomes literally singular: the optimiser finds "riskless" long-short combinations that are pure artifacts and levers into them without limit.
Once you see the problem as "the optimiser amplifies whatever noise you feed it", the fixes arrange themselves on a single spectrum: how much do you dare tell the optimiser?
At the far humble end sits equal weight — tell it nothing. DeMiguel, Garlappi and Uppal (DeMiguel, Garlappi & Uppal 2009) ran the comparison that made this respectable: across seven empirical datasets, none of fourteen sophisticated optimising strategies consistently beat 1/ out of sample on Sharpe ratio. Their estimate of the required data is the sobering part: for a 25-asset portfolio, on the order of 3,000 months of data before classic mean-variance reliably wins. That is 250 years. The paper is sometimes read as "optimisation is useless", which overstates it — it's a statement about estimated unconstrained mean-variance with sample inputs, the worst case. But as a prior, "1/N is hard to beat" should sit permanently on your shoulder.
One step up: risk parity — tell the optimiser about risk but not about returns. Weight positions so each contributes equally to portfolio risk (in the simplest form, weight inversely to volatility). You've dropped the worst-estimated input entirely and kept the best-estimated one, since volatilities are far more stable than means (lesson 4.1's whole premise). Most serious multi-asset frameworks, including the one this guide is steering you toward, are risk-parity-shaped at the core with return forecasts layered on lightly, if at all.
Another step up: keep the estimates but shrink them. Shrinkage is the
same Bayesian move you met in lesson 5.5's beta estimator: drag every noisy
estimate toward a boring structured target, with the pull calibrated to how
noisy the estimate is. Ledoit and Wolf (Ledoit & Wolf 2004) made
this practical for covariance matrices, and their paper's title — "Honey, I
Shrunk the Sample Covariance Matrix" — undersells how useful the result is:
a closed-form, data-driven weight blending the sample covariance
with a simple target (constant correlation), guaranteed better-conditioned,
no tuning required. It is a drop-in replacement in any pipeline
(scikit-learn ships it as LedoitWolf), and there is essentially no reason
ever to use a raw sample covariance in a portfolio context.
At the confident end of the spectrum sits full mean-variance with expected returns — which you should reserve for the rare case where you genuinely believe your return forecasts, and even then with the tight position limits of lesson 4.6, which function as a crude but effective form of shrinkage in their own right.
The maths
Two pieces: why the optimiser explodes, and what shrinkage does.
The unconstrained mean-variance solution, for risk-aversion parameter :
The villain is . Inverting a matrix amplifies its smallest eigenvalues into the largest ones of the inverse — and the smallest eigenvalues of a sample covariance are precisely the ones most distorted by estimation noise. In an ill-conditioned sample , some near-zero eigenvalue represents a spurious "almost riskless" long-short combination; inversion turns it into a dominant direction of , and the optimiser piles on. Meanwhile the multiplication by means any error in a mean estimate transmits linearly into weights, scaled by that same amplification. Noise in, amplified noise out.
Shrinkage replaces each input with a convex combination of estimate and target. For the covariance:
where is the sample covariance, is the structured target (Ledoit- Wolf use the constant-correlation matrix: every pair gets the same correlation, the average one), and is the shrinkage intensity, chosen in closed form to minimise expected error — more data or a cleaner sample pushes down, more noise pushes it up. For means the same logic gives the James-Stein-flavoured , dragging every asset's mean toward the grand mean — with honestly calibrated, most of the cross-sectional variation in your mean estimates gets flattened, which tells you what the data really supports: not much.
Worked example
Three assets, honest-looking annual inputs. True world: all three have identical Sharpe ratios (premium 4%, vol 16%), pairwise correlation 0.5. The fair answer is equal weight. Now estimate the means from 10 years of data: standard error per asset ≈ — larger than the premium itself. A perfectly typical draw:
| Asset | True premium | Estimated premium | MV weight (est.) | MV weight (truth) |
|---|---|---|---|---|
| A | 4.0% | 8.1% | +1.61 | +0.33 |
| B | 4.0% | 1.9% | −0.55 | +0.33 |
| C | 4.0% | 3.5% | +0.27 | +0.33 |
With the true inputs, the optimiser holds the sensible 1/3 each (weights scaled to sum to 1). With the estimated means — each within one standard error of truth, nothing pathological — it levers asset A to 161% and shorts asset B. It has built a concentrated bet on which asset got lucky in sample. Out of sample, A and B perform identically, and the "optimal" portfolio underperforms equal weight while carrying triple the concentration.
import numpy as np
def mv_weights(mu, cov, gamma=3.0):
w = np.linalg.solve(cov, mu) / gamma # Σ⁻¹μ/γ — the error maximiser
return w / np.abs(w).sum()
# the fix, in two lines:
from sklearn.covariance import LedoitWolf
cov_shrunk = LedoitWolf().fit(daily_returns).covariance_ # δ chosen for you
mu_grand = mu_hat.mean()
mu_shrunk = 0.25 * mu_hat + 0.75 * mu_grand # heavy shrink toward "no view"Re-run the table's optimisation with mu_shrunk (75% of the way to the
grand mean) and the weights come out 0.52 / 0.13 / 0.35 — still tilted
toward the lucky asset, but no leverage, no short, and the out-of-sample
damage is a fraction of before. Shrinkage didn't make the estimates right;
it made the optimiser appropriately timid about them.
How you'd use it
- Default to risk-based construction. Inverse-volatility or risk-parity weights across your strategies and assets, with the Ledoit-Wolf covariance, is the sane baseline for a solo systematic trader. It uses only the estimable inputs. Your return views then enter as tilts on this baseline, not as raw optimiser food.
- Never invert a raw sample covariance.
LedoitWolf(or any shrinkage estimator) everywhere, reflexively. This is a one-line change with no downside that removes the explosive failure mode. - If you must use return forecasts, shrink brutally and constrain. Cross-sectional shrinkage toward the grand mean; position bounds (say, no asset beyond 2× its risk-parity weight); no shorts unless the forecast genuinely earns them. Constraints are shrinkage by other means: they stop the optimiser acting on differences you can't defend.
- Benchmark every construction against 1/N (DeMiguel, Garlappi & Uppal 2009) in your backtests, out of sample. If your clever weights don't beat equal weight after costs, use equal weight — it has fewer parameters to be wrong about, and you'll understand its failures faster.
- Spend your complexity budget where estimates are good. Vol forecasts: good — use them (lesson 4.1). Correlations: fair — use them shrunk. Means: poor — mostly don't. This single prioritisation explains most of the distance between naive and professional portfolio construction.
What goes wrong
Optimising anyway, with unshrunk inputs, because the backtest says it works. In-sample, the error maximiser always looks brilliant — it has perfectly fitted the noise you gave it. The whole failure is out of sample, which is why this lesson is really a module-2 lesson wearing portfolio clothes: trust the construction that survives walk-forward testing (lesson 2.5), not the one with the best in-sample frontier.
Shrinking toward a bad target. Shrinkage pulls estimates toward the target's structure; if the target is badly wrong, heavy shrinkage bakes its wrongness in. Constant-correlation is a reasonable default for one asset class, but shrinking a multi-asset-class covariance toward "all pairs equally correlated" flattens the single most reliable structure you have — equities correlate with equities more than with bonds. Use a block-structured target, or shrink within asset classes.
Risk parity's hidden bets. Dropping return estimates doesn't make risk parity assumption-free: it implicitly assumes every asset has a similar Sharpe ratio, and levering low-vol assets to parity imports the funding and deleveraging risks of lesson 5.5 — the levered bond sleeve of a risk parity book is exactly a betting-against-beta position, and it shares the crisis behaviour. Equal risk is not equal safety.
Correlations are estimated in the regime you have, used in the regime you get. Every covariance-based construction inherits lesson 5.5's beta compression problem: correlations estimated in calm markets understate crisis co-movement, so measured diversification overstates true diversification precisely when it matters (lesson 4.3 quantifies this through the effective-bets lens). Stress your construction with a crisis-correlation override — set all within-asset-class pairs to 0.9 and see what your "diversified" book does.
Chasing the optimiser literature. Resampled frontiers, robust optimisation, Black-Litterman, hierarchical risk parity — each has merit, and each is another layer of parameters. For a solo researcher the marginal Sharpe from construction sophistication beyond shrunk-covariance-risk-parity-plus-limits is small; the marginal risk of fooling yourself with a more elaborate in-sample fit is not. Spend the effort on breadth and costs instead — that's where the fundamental law says the money is.