The keyword variance x-y refers to the variance of the difference \(X-Y\) for two random variables \(X\) and \(Y\). The correct formula depends on how strongly \(X\) and \(Y\) move together, measured by covariance.
\[ \mathrm{Var}(X-Y)=\mathrm{Var}(X)+\mathrm{Var}(Y)-2\,\mathrm{Cov}(X,Y). \]
If \(X\) and \(Y\) are independent, then \(\mathrm{Cov}(X,Y)=0\), so \[ \mathrm{Var}(X-Y)=\mathrm{Var}(X)+\mathrm{Var}(Y). \]
Step-by-step derivation
Start from the identities \[ \mathrm{Var}(Z)=\mathbb{E}[Z^2]-\big(\mathbb{E}[Z]\big)^2, \quad \mathrm{Cov}(X,Y)=\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]. \]
Let \(Z=X-Y\). Then \[ \mathrm{Var}(X-Y)=\mathbb{E}\big[(X-Y)^2\big]-\big(\mathbb{E}[X-Y]\big)^2. \]
Expand the square: \[ (X-Y)^2=X^2-2XY+Y^2. \] Taking expectations gives \[ \mathbb{E}\big[(X-Y)^2\big]=\mathbb{E}[X^2]-2\mathbb{E}[XY]+\mathbb{E}[Y^2]. \]
Expand the squared mean: \[ \big(\mathbb{E}[X-Y]\big)^2=\big(\mathbb{E}[X]-\mathbb{E}[Y]\big)^2 =\big(\mathbb{E}[X]\big)^2-2\mathbb{E}[X]\mathbb{E}[Y]+\big(\mathbb{E}[Y]\big)^2. \]
Subtracting, \[ \mathrm{Var}(X-Y) =\big(\mathbb{E}[X^2]-\big(\mathbb{E}[X]\big)^2\big) +\big(\mathbb{E}[Y^2]-\big(\mathbb{E}[Y]\big)^2\big) -2\big(\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]\big). \]
Recognize the definitions: \[ \mathrm{Var}(X-Y)=\mathrm{Var}(X)+\mathrm{Var}(Y)-2\,\mathrm{Cov}(X,Y). \]
Interpretation: how covariance changes variance x-y
- Positive covariance (\(\mathrm{Cov}(X,Y)>0\)) decreases \(\mathrm{Var}(X-Y)\): the variables tend to move together, so their difference is less variable.
- Negative covariance (\(\mathrm{Cov}(X,Y)<0\)) increases \(\mathrm{Var}(X-Y)\): the variables tend to move in opposite directions, so their difference spreads out more.
- Independence implies \(\mathrm{Cov}(X,Y)=0\) (but \(\mathrm{Cov}(X,Y)=0\) does not always imply independence).
Worked numeric example
Suppose \(\mathrm{Var}(X)=25\), \(\mathrm{Var}(Y)=9\), and \(\mathrm{Cov}(X,Y)=6\). Then \[ \mathrm{Var}(X-Y)=25+9-2\times 6=25+9-12=22. \] The standard deviation of \(X-Y\) is \[ \sqrt{22}\approx 4.690. \]
| Scenario | Covariance | \(\mathrm{Var}(X-Y)\) | Comment |
|---|---|---|---|
| Independent (common special case) | \(0\) | \(25+9=34\) | No shared movement; spreads add. |
| Positively associated (example) | \(6\) | \(25+9-12=22\) | Difference is less variable. |
| Negatively associated (illustration) | \(-6\) | \(25+9-2\times(-6)=46\) | Difference is more variable. |
Visualization: decomposing variance x-y into its three terms
Common extensions
- More generally, for constants \(a,b\): \(\mathrm{Var}(aX+bY)=a^2\mathrm{Var}(X)+b^2\mathrm{Var}(Y)+2ab\,\mathrm{Cov}(X,Y)\).
- For \(X+Y\): \(\mathrm{Var}(X+Y)=\mathrm{Var}(X)+\mathrm{Var}(Y)+2\,\mathrm{Cov}(X,Y)\).
- If \(X=Y\), then \(X-Y=0\) and \(\mathrm{Var}(X-Y)=0\); the formula matches because \(\mathrm{Cov}(X,X)=\mathrm{Var}(X)\).