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.
ATTRIBUTION.md3.9 KBLICENSE1.0 KBREADME.md2.6 KBatom_cli.py3.0 KBcomponent.json8.6 KBledoit_wolf_shrinkage.py3.5 KBnumerics.py28.0 KBschema_lite.py8.9 KBtest_ledoit_wolf_shrinkage.py4.3 KBtest_package.py12.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
- Statistics for comparing resultsDeterministic skills
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.