deepdream of
          a sidewalk
Show Question
Math and science::INF ML AI

Covariance matrix

Let X and Y be two random variables. The covariance between X and Y is defined as:

Cov[X,Y]:=E[(XE[X])(YE[Y])]=E[XY]E[X]E[Y]

Let the vector Z be defined like so: Z:=[XY]. Thus, Z is a vector of random variables.

The covariance matrix for Z is defined as:

Cov[Z]:=E[(ZE[Z])(ZE[Z])T]=[Var(X)Cov(X,Y)Cov(X,Y)Var(Y)]

Where the expectation is an elementwise operation. The covariance matrix is a result of a matrix multiplication of two vector-like matrices, which produces a 2x2 matrix. (Yes, it is valid!).


Matrix interpretation

An intepretation of such a 2x1*1x2 matrix multiplication is:

[AB][CD]=[ACADBCBD]=[C(AB)D(AB)]

The first matrix can be considered a transformation matrix which transforms a single dimension into 2 dimensions. A is the factor by which the input scalar is multiplied by to produce the first output dimension; B is the same quantity for the second output dimension. The matrix [CD] can be considered a list of two separate scalars that will be transformed separately.

For the case of ZZT, if Z has D dimensions, then the output is D vectors combined horizontally into a matrix, where each vector is the original Z multiplied by one of it's components.

For the 2 dimensional covariance matrix we have:

Cov[Z]=E[(ZE[Z])(ZE[Z])T]=E[[XμXYμY][XμXYμY]]=E[[(XμX)(XμXYμY)(YμY)(XμXYμY)]]=[Cov(X,X)Cov(Y,X)Cov(X,Y)Cov(Y,Y)]=[Var(X)Cov(X,Y)Cov(X,Y)Var(Y)]

The covariance matrix is symmetric, like all matrixes of the form XXT. Its diagonal is the variances of each random variable.

Random variable interpretation

Covariance is the expected value of the random variable Z=(XX¯)(YY¯). Imagine the probability mass function of X and Y, then XX¯ and YY¯, then the 2 dimensional (XX¯,YY¯), then finally the 1 dimensional Z. The covariance is a single value representing the expectation (product sum) of the value-probabilities of Z.


Use in projected variance

Let \(