Baltor Get started

Library / Code module

Ledoit-Wolf covariance shrinkage

ledoit_wolf_shrinkage

Shrink a sample covariance toward a scaled identity with the Ledoit-Wolf intensity, giving a well-conditioned, positive definite estimate even when there are fewer observations than variables. Use it before inverting a covariance of metrics, features or embeddings estimated from few runs.

Files, names only

  • ATTRIBUTION.md 3.9 KB
  • LICENSE 1.0 KB
  • README.md 2.6 KB
  • atom_cli.py 3.0 KB
  • component.json 8.6 KB
  • ledoit_wolf_shrinkage.py 3.5 KB
  • numerics.py 28.0 KB
  • schema_lite.py 8.9 KB
  • test_ledoit_wolf_shrinkage.py 4.3 KB
  • test_package.py 12.0 KB

Full files in your harness.

What it takes and gives

Runs with
Python 3.10 or later
Entry points
ledoit_wolf, shrink
Known answers
6 cases its tests reproduce

Cases it covers

  • not left singular: With 3 observations of 5 variables the sample covariance is singular; using it unshrunk makes its inverse undefined.

Limits and scope

Limits
Single target (scaled identity); other targets such as constant correlation or a diagonal are not included. The intensity is an estimate of the loss-minimizing value with an asymptotic guarantee, not the oracle intensity for a given small sample. Dense p by p matrices: meant for p up to a few hundred.
Guarantees
shrinkage = min(bbar^2, d^2) / d^2 lies in [0, 1]; it is 0 when the sample covariance is already a multiple of the identity. With shrinkage > 0 and a positive target scale the estimate is positive definite, even when p > n. Scaling the data by c scales the estimate by c^2 and leaves the shrinkage unchanged; rotating the data rotates the estimate.
Assumes
Observations are independent and identically distributed with finite fourth moments (the setting of the consistency result). The sample covariance divides by n, as in the Ledoit-Wolf derivation.

Details

Kind
Code module
Licence
MIT
Declared effects
runs commands
Source
github.com/alisonjieli-png/loop-engine/tools/creative_originals/evaluation_atoms/items/ledoit_wolf_shrinkage
Size
10 files, 75.8 KB
Identity
library.supply.creative_originals.e9e146ec1aab31bae287f33c.20713d30419828ad
Version
20713d30419828ada9081ec467da388c866dd61a6a271d428f96902441f9e41d

The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.

Where it is shown

Related components

Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.