next | previous | forward | backward | up | index | toc

# sampleCovarianceMatrix -- sample covariance matrix of observation vectors

## Synopsis

• Usage:
sampleCovarianceMatrix U
• Inputs:
• U, , or List of sample data
• Outputs:
• , sample covariance matrix of the sample data

## Description

The sample covariance matrix is $S = \frac{1}{n} \sum_{i=1}^{n} (X^{(i)}-\bar{X}) (X^{(i)}-\bar{X})^T$. Note that for normally distributed random variables, $S$ is the maximum likelihood estimator (MLE) for the covariance matrix. This is different from the unbiased estimator, which uses a denominator of $n-1$ instead of $n$.

Sample data is input as a matrix or a list. The rows of the matrix or the elements of the list are observation vectors.

 i1 : L= {{1,2,1,-1},{2,1,3,0},{-1, 0, 1, 1},{-5, 3, 4, -6}}; i2 : sampleCovarianceMatrix(L) o2 = | 115/16 -13/8 -29/16 47/8 | | -13/8 5/4 7/8 -11/4 | | -29/16 7/8 27/16 -21/8 | | 47/8 -11/4 -21/8 29/4 | 4 4 o2 : Matrix QQ <-- QQ i3 : U= matrix{{1,2,1,-1},{2,1,3,0},{-1, 0, 1, 1},{-5, 3, 4, -6}}; 4 4 o3 : Matrix ZZ <-- ZZ i4 : sampleCovarianceMatrix(U) o4 = | 115/16 -13/8 -29/16 47/8 | | -13/8 5/4 7/8 -11/4 | | -29/16 7/8 27/16 -21/8 | | 47/8 -11/4 -21/8 29/4 | 4 4 o4 : Matrix QQ <-- QQ

## Ways to use sampleCovarianceMatrix :

• sampleCovarianceMatrix(List)
• sampleCovarianceMatrix(Matrix)

## For the programmer

The object sampleCovarianceMatrix is .