covmats.CovarianceMatrix#

class covmats.CovarianceMatrix(*args, **kwargs)[source]#

Abstract representation of a covariance matrix.

Calculations involving covariance matrices (e.g. data whitening, multivariate normal function evaluation) are often performed more efficiently using a decomposition of the covariance matrix instead of the covariance matrix itself. This class allows the user to construct an object representing a covariance matrix using any of several decompositions and perform calculations using a common interface.

Note

The CovarianceMatrix class cannot be instantiated directly. Instead, use one of the derived class:

Notes

None of the Covariance child implementation supports singular or indefinite covariance matrices. Otherwise, they would not be invertible, colorizing and whitening would not well defined.

__init__() None[source]#

Initialize the instance.

Properties

H

Hermitian adjoint.

T

Transpose this linear operator.

covariance

Explicit dense representation of the covariance matrix.

log_pdet

Log of the pseudo-determinant of the covariance matrix.

n_pts

Number of points in the domain (n).

ndim

precision

Explicit dense representation of the precision matrix with shape (n, n).

rank

Rank of the covariance matrix.

shape

Shape of the covariance matrix (n, n).

subspace_size

Subspace size of the covariance matrix.

Methods

adjoint

Hermitian adjoint.

colorize

Perform a colorizing transformation on data.

dot

Matrix-matrix or matrix-vector multiplication.

from_cholesky

Representation of a covariance provided via choleksy factorization.

from_diagonal

Representation of a covariance provided via diagonal.

from_eigendecomposition

Representation of a covariance provided via eigendecomposition.

from_precision

Return a representation of a covariance from its precision matrix.

get_diagonal

Return the diagonal entries of the matrix (variances) as a vector (n,).

get_trace

Return the trace of the covariance matrix (sum of diagonal elements).

matmat

Matrix-matrix multiplication.

matvec

Matrix-vector multiplication.

rmatmat

Adjoint matrix-matrix multiplication.

rmatvec

Adjoint matrix-vector multiplication.

sample_mvnormal

Draw samples from the multivariate normal N(0, A).

solve

Solve Ax = b, with A, the current covariance matrix instance.

todense

Explicit dense representation of the covariance matrix with shape (n, n).

transpose

Transpose this linear operator.

whiten

Perform a whitening transformation on data.