freealg.trace#
- freealg.trace(A, N=None, p=1.0)#
Estimate the trace of a power of a Hermitian matrix.
This function estimates the trace of the matrix power \(\mathbf{A}^p\) or that of a larger matrix containing \(\mathbf{A}\).
- Parameters:
- Anumpy.ndarray
The symmetric real-valued matrix \(\mathbf{A}\) whose trace of a power (or that of a matrix containing \(\mathbf{A}\)) is to be computed.
- Nint, default=None
The size of the matrix containing \(\mathbf{A}\) to estimate eigenvalues of. If None, returns estimates of the eigenvalues of \(\mathbf{A}\) itself.
- pfloat, default=1.0
The exponent \(p\) in \(\mathbf{A}^p\).
- Returns:
- tracefloat
matrix trace
Notes
The trace is highly amenable to subsampling: under free decompression the average eigenvalue is assumed constant, so the trace increases linearly. Traces of powers fall back to
freealg.eigh()
.Examples
>>> from freealg import norm >>> from freealg.distributions import MarchenkoPastur >>> mp = MarchenkoPastur(1/50) >>> A = mp.matrix(3000) >>> trace(A, 100_000)