> [!NOTE] Definition (Covariance of Discrete Real-Valued Random Variables)
> Let $X, Y$ be [[Square-Integrable Discrete Real-Valued Random Variable|square-integrable discrete real-valued random variables]]. The *covariance* of $X$ and $Y$ is given by $\text{Cov}(X,Y)= \mathbb{E}[(X-\mathbb{E}[X])(Y-\mathbb{E}[Y])]$where $\mathbb{E}[X]$ denotes the [[Expectation of Discrete Real-Valued Random Variable|expectation]] of $X.$
# Properties
By [[Covariance of Square-Integrable Discrete Real-Valued Random Variables as Expectation of Product minus Product of Expectations]], $\text{Cov}(X,Y)=\mathbb{E}[XY]-\mathbb{E}[X]\cdot \mathbb{E}[Y].$
By [[Covariance of Square Integrable Discrete Real-Valued Random Variables is Symmetric]], $\text{Cov}(X,Y)= \text{Cov}(Y,X).$
By [[Covariance of Square Integrable Discrete Real-Valued Random Variable with Itself]], $\text{Cov}(X,X)=\text{Var}(X).$
By [[Covariance Square Integrable Discrete Real-Valued Random Variables is Bilinear]], $\text{Cov}\left( \sum_{j=1}^{n} a_{j}X_{j}, \sum_{k-1}^{m} b_{k}Y_{k} \right)=\sum_{j=1}^{n}\sum_{k=1}^{m} a_{j}, b_{k} \text{Cov}(X_{j},Y_{k})$ (in particular, $\text{ Cov}(aX+bY,Z)=a\text{Cov(X,Z)}+b\text{Cov}(Y,Z)$).
# Applications
**Sample variance**: By [[Variance of Sum of Square-Integrable Discrete Real-Valued Random Variables]], $\text{Var}\left( \sum_{i=1}^{n} X_{i} \right)=\sum_{i=1}^{n} \text{Var}(X_{i})+ \sum_{j \neq k} \text{Cov}(X_{j},X_{k}).$
**Correlation**: We say that two square-integrable discrete real-valued random variables are [[Uncorrelated Square-Integrable Discrete Real-Valued Random Variables|uncorrelated]] if their covariance is zero. The [[Correlation Coefficient of Square-Integrable Discrete Real-Valued Random Variables|Pearson correlation coefficient]] of discrete random variables $X$ and $Y$ is given by $\rho(X,Y)=\frac{\text{Cov}(X,Y)}{\sigma(X)\cdot \sigma(Y)}.$ Note that $|\rho(X,Y)|\leq 1$ and $a,b,c,d\in \mathbb{R},$ $\rho(aX+b,cY+d)=\rho(X,Y).$