Skip to content

Ledoit–Wolf covariance estimator

Estimate identity-target covariance shrinkage from the data, follow a checked two-asset example, and separate matrix-error optimality from portfolio performance.

The Ledoit–Wolf covariance estimator estimates a covariance matrix by blending the empirical matrix with a structured target, using an intensity estimated from the data. Its practical purpose is to reduce estimation noise before a risk model or portfolio optimiser amplifies that noise through matrix inversion.
This page covers the scaled-identity version implemented by scikit-learn's LedoitWolf. Covariance shrinkage is the broader family: choosing an arbitrary 20% blend is shrinkage, but does not make the coefficient a Ledoit–Wolf estimate. Other Ledoit–Wolf papers use other targets; the portfolio paper Honey, I Shrunk the Sample Covariance Matrix uses a constant-correlation target, which retains unequal sample variances. These procedures should not be interchanged under one label. See the original portfolio paper, §3.2.

The target and the fitted weight

Let nn observations of pp variables form the rows of a matrix. Subtract each column's sample mean to obtain centred row vectors xt⊤\mathbf{x}_t^\top. Define

S=1n∑t=1nxtxt⊤,μ=tr⁡(S)p.S=\frac{1}{n}\sum_{t=1}^{n}\mathbf{x}_t\mathbf{x}_t^\top, \qquad \mu=\frac{\operatorname{tr}(S)}{p}.
Here μ\mu means average sample variance, not the mean-return vector. The estimator is
Σ^LW=(1−α^)S+α^μI,0≤α^≤1.\widehat\Sigma_{\mathrm{LW}} =(1-\widehat\alpha)S+\widehat\alpha\mu I, \qquad 0\leq\widehat\alpha\leq1.
The target has zero off-diagonal covariances and the same variance μ\mu for every variable. It is a stabilising reference, rather than a finding that assets are independent. Off-diagonal entries are multiplied by 1−α^1-\widehat\alpha; individual variances move toward their average. The trace stays unchanged. The official estimator documentation specifies this target and its fitted coefficient.

For D>0D>0, a convenient expression matching the software convention is

B=1n2∑t=1n∥xtxt⊤−S∥F2,D=∥S−μI∥F2,α^=min⁡(BD,1).\begin{aligned} B&=\frac{1}{n^2}\sum_{t=1}^{n} \left\lVert\mathbf{x}_t\mathbf{x}_t^\top-S\right\rVert_F^2,\\ D&=\left\lVert S-\mu I\right\rVert_F^2,\\ \widehat\alpha&=\min\left(\frac{B}{D},1\right). \end{aligned}
The squared Frobenius norm sums the squares of all matrix entries, including both symmetric off-diagonal entries. BB estimates sampling noise from the variability of the individual outer products. DD measures the empirical matrix's distance from the target. More estimated noise relative to that distance means more shrinkage. Dividing both BB and DD by pp, as in the paper's norm convention, leaves their ratio unchanged. If D=0D=0, S=μIS=\mu I already, so every blend produces the same matrix; the software returns zero shrinkage in this degenerate case. The implementation makes the centring, normalisations and upper bound explicit.
“Optimal” has a specified meaning. The original result concerns quadratic covariance error, E[∥Σ^−Σ∥F2]/p\mathbb{E}[\lVert\widehat\Sigma-\Sigma\rVert_F^2]/p, within linear combinations of the empirical covariance and identity. The unknown oracle coefficients are replaced by estimable quantities, with asymptotic optimality as dimension and sample size grow with p/np/n bounded. It is not exact finite-sample knowledge of the best coefficient. The analysis assumes independent, identically distributed, mean-zero observation vectors, bounded average eighth moments and a technical restriction on cross-coordinate products. “Distribution-free” here does not mean assumption-free or robust to arbitrary tails and dependence. Ledoit and Wolf (2004), §§2–3, state the loss, estimator and assumptions.

Eight fictional return observations

Suppose two assets have the following aligned one-period returns, recorded in percentage points:
ObservationAsset AAsset B
1−3−2
2−2−1
3−1−1
400.5
511
622
731.5
80−1

Both sample means happen to be zero. Using the n=8n=8 divisor gives

S=(3.52.31252.31251.8125),μ=2.65625.S=\begin{pmatrix}3.5&2.3125\\2.3125&1.8125\end{pmatrix}, \qquad \mu=2.65625.

All entries have units of percentage points squared (pp²). The outer-product calculation gives B=2.87158203125B=2.87158203125 and D=12.119140625D=12.119140625, both in pp⁴. Consequently,

α^=0.236946…,Σ^LW≈(3.3000771.7645621.7645622.012423) pp2.\widehat\alpha=0.236946\ldots, \qquad \widehat\Sigma_{\mathrm{LW}}\approx \begin{pmatrix} 3.300077&1.764562\\ 1.764562&2.012423 \end{pmatrix}\ \text{pp}^2.

The 23.69% weight was calculated from these observations. It was not selected to make a portfolio look smoother.

For the fictional sample, the smaller covariance eigenvalue rises from 0.194631 to 0.777901 pp² and the larger falls from 5.117869 to 4.534599 pp² at fitted shrinkage 0.236946. Both approach the target 2.65625 pp² as shrinkage approaches one. The spectral condition number falls from 26.30 to 5.83.
For the fictional sample, the smaller covariance eigenvalue rises from 0.194631 to 0.777901 pp² and the larger falls from 5.117869 to 4.534599 pp² at fitted shrinkage 0.236946. Both approach the target 2.65625 pp² as shrinkage approaches one. The spectral condition number falls from 26.30 to 5.83.
Original calculation from the eight fictional observations. The lines show candidate blends; the markers show the data-estimated intensity. They do not show forecast performance.
For a sample eigenvalue λi\lambda_i, the blend has eigenvalue
λ^i=(1−α^)λi+α^μ.\widehat\lambda_i=(1-\widehat\alpha)\lambda_i+\widehat\alpha\mu.

The sample eigenvectors remain eigenvectors of the blend. This explains the figure: the small directional variance is lifted, so its reciprocal has less influence in the inverse. If SS is positive semidefinite, α^>0\widehat\alpha>0 and μ>0\mu>0, the result is positive definite even when SS is singular. Those last two conditions matter: shrinkage cannot manufacture positive risk from all-zero data.

Conventions that change the result

The divisor is nn, not n−1n-1. The ordinary unbiased sample covariance after estimating a mean uses n−1n-1. This fitted estimator instead uses the nn-divisor empirical matrix and a matching noise formula. Substituting one convention into only part of the calculation produces a different procedure.
Centring and a known zero mean are different choices. By default, scikit-learn estimates and subtracts the column means. With assume_centered=True, it uses the input as supplied. If the population mean is genuinely known to be zero, the latter uses the appropriate second moments without estimating a mean. A nonzero mean left untreated adds a mean outer product to the covariance target. Fit means on the training sample when evaluating future data; using future observations for centring leaks information. The two choices coincide in this particular table because its sample means are exactly zero. The official API documents the centring switch.
The units must be coherent. Converting every return from percentage points to decimal returns multiplies SS, the target and the final estimate by 10−410^{-4}, while leaving the intensity unchanged. Rescaling only one variable changes the equal-variance target and can change the intensity. Identity-target shrinkage therefore depends on the chosen relative scales.

A better-conditioned inverse is not a portfolio guarantee

For an unconstrained, fully invested minimum-variance portfolio, the weights are proportional to Σ^−11\widehat\Sigma^{-1}\mathbf{1}. In this example, using SS gives weights approximately (−0.7273,1.7273)(-0.7273,1.7273); using the shrunk estimate gives (0.1390,0.8610)(0.1390,0.8610). These are two fitted portfolios under identical budget constraints, with short selling allowed. Their difference shows sensitivity to the risk estimate. It does not establish which has lower future variance.
Covariance error is not the same objective as realised portfolio risk after constraints, transaction costs and changing market conditions. Serial dependence and volatility shifts also challenge the iid sampling model, while extreme observations can strongly affect empirical moments. The covariance-estimation guide discusses both the iid assumption and outlier sensitivity. Assess the full portfolio procedure on chronologically held-out data, fitting shrinkage afresh inside each training window.
For the optimisation mechanics, Mean–Variance Optimisation derives the inverse-covariance weights and explains their instability. Its public page is a preview; the full lesson requires membership.

Sources

Last updated
  • covariance estimation
  • ledoit wolf
  • shrinkage
  • portfolio risk
  • matrix conditioning
← Back to the glossaryBack to top ↑