numpy.ma.cov

numpy.ma.cov(x, y=None, rowvar=True, bias=False, allow_masked=True)

Estimates the covariance matrix.

Normalization is by (N-1) where N is the number of observations (unbiased estimate). If bias is True then normalization is by N.

By default, masked values are recognized as such. If x and y have the same shape, a common mask is allocated: if x[i,j] is masked, then y[i,j] will also be masked. Setting allow_masked to False will raise an exception if values are missing in either of the input arrays.

Parameters:

x : array_like

Input data. If x is a 1D array, returns the variance. If x is a 2D array, returns the covariance matrix.

y : array_like, optional

Optional set of variables.

rowvar : {False, True} optional

If rowvar is true, then each row is a variable with observations in columns. If rowvar is False, each column is a variable and the observations are in the rows.

bias : {False, True} optional

Whether to use a biased (True) or unbiased (False) estimate of the covariance. If bias is True, then the normalization is by N, the number of observations. Otherwise, the normalization is by (N-1).

allow_masked : {True, False} optional

If True, masked values are propagated pair-wise: if a value is masked in x, the corresponding value is masked in y. If False, raises a ValueError exception when some values are missing.

Raises:

ValueError: :

Raised if some values are missing and allow_masked is False.

Previous topic

numpy.ma.corrcoef

Next topic

numpy.ma.cumsum

This Page

Quick search