pub fn covariance_row_features<T: Numeric>(matrix: &Matrix<T>) -> Matrix<T> where
    for<'a> &'a T: NumericRef<T>, 
Expand description

Computes the covariance matrix for an NxM feature matrix, in which each M’th column has N features to find the covariance and variance of.

The covariance matrix is a matrix of how each feature varies with itself (along the diagonal) and all the other features (symmetrically above and below the diagonal).

Each element in the covariance matrix at (i, j) will be the variance of the ith and jth features from the feature matrix, defined as the zero meaned dot product of the two feature vectors divided by the number of samples.

If all the features in the input have a variance of one then the covariance matrix returned by this function will be equivalent to the correlation matrix of the input

This function does not perform Bessel’s correction

Panics

If the numeric type is unable to represent the number of samples for each feature (ie if T: i8 and you have 1000 samples) then this function will panic.

Warning

With some uses of this function the Rust compiler gets confused about what type T should be and you will get the error:

overflow evaluating the requirement &'a _: easy_ml::numeric::NumericByValue<_, _>

In this case you need to manually specify the type of T by using the turbofish syntax like: linear_algebra::covariance::<f32>(&matrix)

Alternatively, the compiler doesn’t seem to run into this problem if you use the equivalent methods on the matrix type like so: matrix.covariance_row_features()