Expectation and Variance of a Sum of Two Random Variables, Including Covariance
GleanData Scientist · OnsiteLast updated
Asks how to compute the expectation and variance of the sum of two random variables, in general and when they are independent. Tests derivation from definitions, the role of covariance, generalizing to weighted sums and differences, and applying the result to data-science problems such as comparing group means.
In a hiring-manager interview for a data scientist role, the statistics question was: how do you compute the expectation and the variance of the sum of two random variables?
Answer for two random variables $X$ and $Y$ in general, then say what changes when they are independent.
Clarifying Questions
- Are $X$ and $Y$ independent, correlated, or of unknown dependence?
- Does the interviewer want a derivation, or the result and how it is used?
Hints
Hint 1
Expectation first: Write the expectation of the sum directly from the definition, and notice which assumption you never needed.
Hint 2
Expand the square: Write the variance of the sum as the expectation of a squared deviation and expand it. One term will not disappear on its own.
Follow-up questions
- What is the variance of $X - Y$?
- If $X$ and $Y$ each have standard deviation $\sigma$, what range of values can the standard deviation of $X + Y$ take?
- Two independent fair dice are rolled. What are the mean and the variance of their total?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.