cov

Contents

cov#

class saiunit.math.cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None, unit_to_scale=None, **kwargs)#

Estimate a covariance matrix, given data and weights.

Covariance indicates the level to which two variables vary together. If we examine N-dimensional samples, \(X = [x_1, x_2, ... x_N]^T\), then the covariance matrix element \(C_{ij}\) is the covariance of \(x_i\) and \(x_j\). The element \(C_{ii}\) is the variance of \(x_i\).

See the notes for an outline of the algorithm.

Parameters:
  • m (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – A 1-D or 2-D array containing multiple variables and observations. Each row of m represents a variable, and each column a single observation of all those variables. Also see rowvar below.

  • y (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity | None) – An additional set of variables and observations. y has the same form as that of m.

  • rowvar (bool) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

  • bias (bool) – Default normalization (False) is by (N - 1), where N is the number of observations given (unbiased estimate). If bias is True, then normalization is by N. These values can be overridden by using the keyword ddof in numpy versions >= 1.5.

  • ddof (int | None) – If not None the default value implied by bias is overridden. Note that ddof=1 will return the unbiased estimate, even if both fweights and aweights are specified, and ddof=0 will return the simple average. See the notes for the details. The default value is None.

  • fweights (Array | ndarray | bool | number | bool | int | float | complex | None) – 1-D array of integer frequency weights; the number of times each observation vector should be repeated.

  • aweights (Array | ndarray | bool | number | bool | int | float | complex | None) – 1-D array of observation vector weights. These relative weights are typically large for observations considered “important” and smaller for observations considered less “important”. If ddof=0 the array of weights can be used to assign probabilities to observation vectors.

  • unit_to_scale (saiunit.Unit | None) – The unit to scale the x.

Returns:

out – The covariance matrix of the variables.

Return type:

Array