An m-D vector can be represented as an m x 1 matrix. A transpose of an m x n matrix A denoted by AT is an nxm matrix with

Observe that the definition of matrix multiplication allows us to multiply non-square matrices, i.e. one can always multiply an m x d matrix with an d x n matrix with the product being an m x n matrix.

Let xi , 1<=i<=n, be n 2-D vectors. Their average is given by


Their sample covariance matrix, A, is given by
Once you have the sample covariance matrix A, the eigenvalues are roots of the equation det(A - xI), where xI is x times the Identity matrix and det stands for determinant

The equation you get is a quadratic equation in x, which you need to now solve to get the eigenvalues.

Test Cases

  1. Vectors: [1 -1]T, [2 -2]T, [3 -3]T.
    Covariance matrix:
    1  -1
    -1  1
    Eigenvalues: 0, 2.
  2. Vectors: [1 7]T, [9 13]T, [-9 -3]T.
    Covariance matrix:
    81.3333 72.6667
    72.6667 65.3333
    Eigenvalues: 0.2276, 146.4390.


Available under the terms of the GNU Free Documentation Licence