bundles / scipy latest / scipy / stats / _covariance / Covariance
class
scipy.stats._covariance:Covariance
source: /scipy/stats/_covariance.py :12
Signature
class Covariance ( ) Members
-
__init__ -
_validate_matrix -
_validate_vector -
colorize -
from_cholesky -
from_diagonal -
from_eigendecomposition -
from_precision -
whiten
Summary
Representation of a covariance matrix
Extended Summary
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.
Examples
The `Covariance` class is used by calling one of its factory methods to create a `Covariance` object, then pass that representation of the `Covariance` matrix as a shape parameter of a multivariate distribution. For instance, the multivariate normal distribution can accept an array representing a covariance matrix:from scipy import stats import numpy as np d = [1, 2, 3] A = np.diag(d) # a diagonal covariance matrix x = [4, -2, 5] # a point of interest dist = stats.multivariate_normal(mean=[0, 0, 0], cov=A)✓
dist.pdf(x)
✗cov = stats.Covariance.from_diagonal(d) dist = stats.multivariate_normal(mean=[0, 0, 0], cov=cov)✓
dist.pdf(x)
✗Aliases
-
scipy.stats.Covariance