mixle.analysis.covariance_shrinkage module

Ledoit-Wolf covariance-shrinkage estimator for the multivariate Gaussian.

The sample covariance is a poor estimate when the number of observations is not large relative to the dimension: its extreme eigenvalues are biased (the largest too large, the smallest too small), which is exactly what wrecks anything that inverts it – Markowitz portfolios, Mahalanobis distances, GP precisions. Ledoit and Wolf (2004, A well-conditioned estimator for large-dimensional covariance matrices) give the optimal convex combination of the sample covariance S and a well-conditioned target F (a scaled identity F = (tr S / d) I):

Sigma_hat = (1 - delta) S + delta F, delta = clip( b^2 / d^2 , 0, 1 ),

where d^2 = ||S - F||_F^2 and b^2 = (1/n^2) sum_t ||y_t y_t^T - S||_F^2 (y_t the centered observations) – a data-driven shrinkage intensity, no cross-validation needed.

LedoitWolfEstimator is a first-class mixle estimator: it follows the accumulator/factory/encoder contract, so it composes with estimate, mixtures, HMMs, and anything else that takes a ParameterEstimator, and it returns an ordinary MultivariateGaussianDistribution. The shrinkage intensity is computed exactly from streaming sufficient statistics – the centered 4th moment sum_t (y_t . y_t)^2 decomposes into sum x, sum x x^T, sum x ||x||^2 and sum ||x||^4 – so it works under seq_update and combine (distributed) without holding the data.

Reference: Ledoit & Wolf, ‘A well-conditioned estimator for large-dimensional covariance matrices’, J. Multivariate Anal. (2004).

class LedoitWolfEstimator(dim=None, name=None, keys=None)[source]

Bases: ParameterEstimator

Estimate a multivariate Gaussian with a Ledoit-Wolf-shrunk covariance.

Returns a MultivariateGaussianDistribution whose mean is the sample mean and whose covariance is shrunk toward a scaled identity by the data-driven Ledoit-Wolf intensity. The chosen intensity is exposed on the returned distribution as dist.shrinkage for inspection.

Parameters:
  • dim (int | None)

  • name (str | None)

  • keys (str | None)

accumulator_factory()[source]
Return type:

LedoitWolfAccumulatorFactory

estimate(nobs, suff_stat)[source]
Return type:

MultivariateGaussianDistribution