Skip to main content

OAS

#include <Skigen/Covariance>

template <typename Scalar = double>
class Skigen::OAS(assume_centered=false)

Oracle Approximating Shrinkage (OAS) covariance estimator.

Estimates the covariance matrix using the OAS shrinkage formula, which provides an improved estimate over Ledoit-Wolf for Gaussian data.

The estimator computes:

Σ^=(1ρ)S+ρμI\hat{\Sigma} = (1 - \rho)\,S + \rho\,\mu\,I

where the shrinkage coefficient ρ\rho is given by:

ρ=(12/p)tr(S2)+tr(S)2(n+12/p)(tr(S2)tr(S)2/p)\rho = \frac{(1 - 2/p)\,\mathrm{tr}(S^2) + \mathrm{tr}(S)^2} {(n + 1 - 2/p)\,\bigl(\mathrm{tr}(S^2) - \mathrm{tr}(S)^2/p\bigr)}

Reference: Chen, Wiesel, Eldar & Hero (2010), "Shrinkage Algorithms for MMSE Covariance Estimation", IEEE Trans. Signal Processing, 58(10), 5016-5029.

Mirrors sklearn.covariance.OAS.


Parameters:

  • assume_centered : bool, default=false If true, data is assumed centered (bool, default false).

Attributes:

  • covariance : MatrixType Estimated covariance matrix (p × p).

  • shrinkage : Scalar Shrinkage coefficient ρ ∈ [0, 1].

  • location : RowVectorType Estimated location (mean) of the data (1 × p).


Methods

fit(X)

Fit the OAS covariance model.

Parameters:

  • X : MatrixType Data matrix of shape (n_samples, n_features).

Returns:

  • result : OAS Reference to the fitted estimator (*this).

score(X)

Return the Gaussian log-likelihood of X under the fitted model.

Parameters:

  • X : MatrixType Data matrix of shape (n_samples, n_features).

Returns:

  • result : Scalar Average log-likelihood per sample.

Example

Skigen::OAS<double> oas;
oas.fit(X);

std::cout << "=== OAS ===\n"
<< "Shrinkage coefficient: " << oas.shrinkage() << "\n"
<< "Covariance (4x4):\n" << oas.covariance() << "\n\n";