- [[expected value|expectation]] # Idea Properties of [[covariance]]. ## Constants cannot covary $ \operatorname{Cov}(X, c)=0 $ ```r x <- rnorm(100) constant <- rep(5, 100) # constant 5 cov(x, constant) # = 0 ``` ## Variance is a covariance of a variable with itself The variance of $X$ is the covariance of $X$ with itself: $ \operatorname{Var}(X)=E\left(D_X^2\right)=E\left(D_X D_X\right)=\operatorname{Cov}(X, X) $ where $D$ is deviance. ```r x <- rnorm(5) var(x) == cov(x, x) ``` ## Covariance is symmetric $ \operatorname{Cov}(Y, X)=\operatorname{Cov}(X, Y) $ ```r x <- rnorm(5) y <- rnorm(5) cov(x, y) == cov(y, x) ``` ## Distributive or addition rule $Cov(X + Y, Z) = Cov(X, Z) + Cov(Y, Z)$ $Cov(X, Y+Z) = Cov(X, Y) + Cov(X, Z)$ ```r x <- rnorm(10) y <- rnorm(10) z <- rnorm(10) cov(x + y, z) cov(x, z) + cov(y, z) ``` ### Examples Let $x$ and $y$ be independent and suppose $Var(x) = 10$. Find $cov(x, x+y)$. $cov(x, x+y) = cov(x, x) + cov(x,y)$ $cov(x, x+y) = var(x) + cov(x,y)$ $cov(x, x+y) = 10 + cov(x,y)$ $cov(x, x+y) = 10 + 0$ $cov(x,y) = 0$ because $x$ and $y$ are independent. ## Bilinearity $ \operatorname{Cov}(a X, b Y)=a b \operatorname{Cov}(X, Y) $ $ \operatorname{Cov}(a X+b Y, c Z)=a c \operatorname{Cov}(X, Z)+b c \operatorname{Cov}(Y, Z) $ ```r cov(2 * x, 3 * y) cov(x, y) * 2 * 3 cov(2 * x + 3 * y, 4 * z) (cov(x, z) * 2 * 4) + (cov(y, z) * 3 * 4) ``` ## Examples $ \operatorname{Cov}(10 X-Y, 3 Y+Z)=30 \operatorname{Cov}(X, Y)+10 \operatorname{Cov}(X, Z)-3 \operatorname{Cov}(Y, Y)-\operatorname{Cov}(Y, Z) $ # References - [13.2. Properties of Covariance — Data 140 Textbook](http://prob140.org/textbook/content/Chapter_13/02_Properties_of_Covariance.html) - [Lesson 30 Properties of Covariance | Introduction to Probability](https://dlsun.github.io/probability/cov-properties.html)