What is covariance and what is its formula?

What is covariance and what is its formula?


For two-dimensional random variables (x, y), if x and y are independent, then E {[x-e (x)] [y-e (y)]} = 0
According to the inverse negative proposition, if the formula e {[x-e (x)] [y-e (y)]} is not equal to 0, then x and y are not independent of each other, and X and y are not independent of each other, then there is a certain relationship. This relationship is represented by the formula e {[x-e (x)] [y-e (y)]}, and the quantity represented by this formula is called the covariance of X and y
For two-dimensional random variables (x, y), if e (x), e (y) and E {[x-e (x)] [y-e (y)]} exist, then E {[x-e (x)] [y-e (y)]} is called the covariance (or correlation distance) of X and y, which is recorded as cov (x, y)
Cov(X,Y)=E{ [ X-E(X) ] [ Y-E(Y) ] }
The conclusions are as follows
1. If x and y are independent, then cov (x, y) = 0
2. Expand the covariance formula (put e in brackets)
Cov(X,Y)=E{ [ X-E(X) ] [ Y-E(Y) ] }
=E[ XY-XE(Y)-YE(X)+E(X)E(Y)]
=E(XY)-E[XE(Y)]-E[YE(X)]+E[ E(X)E(Y) ]
=E(XY)-E(X)E(Y)-E(Y)E(X)+E(X)E(Y)
=E(XY)-E(X)E(Y)
--------This formula is another covariance formula
(because e (x) and E (y) are known expected values, they are constants, e (x) e (y) is also a constant, and the expectation of a constant is the constant itself, so EE (x) = e (x), EE (y) = e (y), E [e (x) e (y)] = e (x) e (y))



How to find covariance matrix
Two matrices can only get one covariance value. How to get the covariance matrix? How to understand the covariance matrix


Two parameters can only get one covariance difference, but the general form of SPSS is a two-dimensional table, similar to the concept of point matrix~
As for your point, I think there should be more parameters (not necessarily limited to two), so that we can form the covariance matrix in the strict sense~



Why use inverse matrix for covariance matrix in Mahalanobis distance formula?
The covariance matrix of Mahalanobis distance requires inverse matrix. Sometimes there is no inverse matrix. Why must inverse matrix be used? What is the relationship between inverse matrix and original covariance matrix?


Covariance matrices are all positive definite, so there must be inverse. The reason for using inverse matrix is to remove the influence of scale on distance. If you think about one-dimensional case, you can understand it. For example, the same distance is 3, but for data with large variance, the distance is small, so you need to divide the distance by variance, and the high-dimensional case is the inverse of covariance matrix~