polars_online.corr.mp_density

polars_online.corr.mp_density(lam: Any, n: int, m: int, sigma2: float = 1.0) → Any[source]

Compute the Marchenko-Pastur density at given eigenvalues.

Use it to draw a correlation matrix’s spectrum against the curve pure noise would give. For the edges alone, use mp_edge().

Parameters

lam

An eigenvalue, or an array of them.

n, m, sigma2

As for mp_edge().

Returns

A float array of lam’s shape, 0 outside the edges:

(Q / (2 pi sigma2)) * sqrt((lam_plus - lam) * (lam - lam_minus)) / lam

with Q, lam_plus and lam_minus those of mp_edge().

Raises

ValueError

As for mp_edge().

Examples

print(po.corr.mp_density([0.1, 1.0, 3.0], n=400, m=100).round(3))
[0.    0.616 0.   ]

See also