Expectation and Variance of the Sum of Two Random Variables
Company: Glean
Role: Data Scientist
Category: Statistics & Math
Difficulty: medium
Interview Round: HR Screen
Let X and Y be two random variables. How do you calculate $E[X + Y]$ and $\operatorname{Var}(X + Y)$?
The report asks only for the two calculations. This version also asks you to derive each result and to state what each one assumes about X and Y.
```hint Start from the definition
Write the variance of $Z = X + Y$ as the expected squared deviation of Z from its mean, and expand the square.
```
```hint Where dependence enters
As you derive each result, note which step, if any, needs X and Y to be independent.
```
### Clarifying Questions
- Are X and Y independent, or should the formulas hold for any joint distribution?
- May we assume both variables have finite means and variances?
- Is a derivation for discrete variables enough, or should it also cover continuous ones?
### What a Strong Answer Covers
- Linearity of expectation, derived from the joint distribution, with the point that it needs no independence
- The variance of a sum including the covariance term, derived by expanding the square
- The definition of covariance, when the cross term vanishes, and the difference between uncorrelated and independent variables
- The moment conditions each result needs, and a sanity check on extreme cases such as $Y = X$ or $Y = -X$
### Follow-up Questions
- What are $\operatorname{Var}(X - Y)$ and $\operatorname{Var}(aX + bY + c)$ for constants a, b and c?
- Can $\operatorname{Var}(X + Y)$ be smaller than $\operatorname{Var}(X)$? Give an example.
- In an A/B test, what is the variance of the difference between the treatment and control sample means, and why is there no covariance term?
- Give two random variables that are uncorrelated but not independent.
Overview: A probability fundamentals question: for two random variables X and Y, derive the expectation and the variance of their sum and state what each result assumes. It tests linearity of expectation, the covariance term in the variance of a sum, and the difference between uncorrelated and independent variables.
Read the full Glean Data Scientist interview experience this question came from