WalzoneInterview Prep
πŸ“ž Interviewing soon? Practice with a realistic AI mock phone interview β€” it calls you, then scores you. First 15 min FREE β†’

Wall Street Quant Β· Probability Β· question 84 of 155

What is the difference between correlation and covariance?

πŸ“• Buy this interview preparation book: 155 Wall Street Quant questions & answers β€” PDF + EPUB for $5

Correlation and covariance are both statistical measures that describe the relationship between two random variables. However, they differ in terms of the information they convey, their range of values, and their interpretability. Let me explain each in detail and provide some examples.

1. Covariance:

Covariance measures the joint variability of two random variables. It tells you whether the variables tend to move together (positive covariance), in opposite directions (negative covariance), or are unrelated (zero covariance). The formula for the sample covariance between variables X and Y is:


$$S_{XY} = \frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})$$

where:

- n is the number of data points

- xi is the i-th data point of the variable X

- yi is the i-th data point of the variable Y

- xΜ„ is the sample mean of X

- yΜ„ is the sample mean of Y

The covariance has units that are the product of the units of the two variables. This makes its interpretation difficult, as it depends on the scale of the variables.

2. Correlation:

Correlation is a standardized measure of the linear relationship between two random variables. Unlike covariance, correlation is dimensionless and ranges from -1 to 1. A correlation of -1 indicates a perfect negative linear relationship, 1 indicates a perfect positive linear relationship, and 0 indicates no linear relationship. The formula for the sample correlation (Pearson correlation coefficient) between variables X and Y is:


$$r_{XY} = \frac{S_{XY}}{S_X S_Y} = \frac{\frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\frac{1}{n-1}\sum_{i=1}^n(x_i - \bar{x})^2}\cdot\sqrt{\frac{1}{n-1}\sum_{i=1}^n(y_i - \bar{y})^2}}$$

where:

- SXY is the sample covariance between X and Y

- SX is the sample standard deviation of X

- SY is the sample standard deviation of Y

Since correlation is a standardized measure, it is easier to interpret than covariance. A correlation value close to -1 or 1 suggests a strong linear relationship between the variables, while a value close to 0 suggests little to no linear relationship.

Example:

Let’s consider two variables, X and Y, with the following data points:

X = {1, 2, 4, 6} Y = {2, 3, 5, 8}

We will calculate the covariance and correlation between these variables. First, calculate the means:

$\bar{x} = \frac{1 + 2 + 4 + 6}{4} = 3.25$ $\bar{y} = \frac{2 + 3 + 5 + 8}{4} = 4.5$

Now, calculate the covariance:


$$\begin{aligned} S_{XY} &= \frac{1}{4 - 1}\left\{(1-3.25)(2-4.5) + (2-3.25)(3-4.5) \right.\\ &\left. + (4-3.25)(5-4.5) + (6-3.25)(8-4.5)\right\} \\ &= 3.6667\end{aligned}$$

Next, calculate the standard deviations:


$$S_X = \sqrt{\frac{1}{4-1}\left[(1-3.25)^2 + (2-3.25)^2 + (4-3.25)^2 + (6-3.25)^2\right]} = 1.8925$$


$$S_Y = \sqrt{\frac{1}{4-1}\left[(2-4.5)^2 + (3-4.5)^2 + (5-4.5)^2 + (8-4.5)^2\right]} = 2.2913$$

Finally, calculate the correlation:


$$r_{XY} = \frac{3.6667}{1.8925\cdot 2.2913} = 0.9690$$

The covariance between X and Y is 3.6667, which suggests a positive relationship between the two variables. The correlation between X and Y is 0.9690, close to 1, indicating a strong positive linear relationship between the variables.

In conclusion, covariance and correlation both measure the relationship between two variables; however, correlation is more easily interpretable since it is a standardized measure that ranges from -1 to 1, while covariance depends on the scale of the variables.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Wall Street Quant interview β€” then scores it.
πŸ“ž Practice Wall Street Quant β€” free 15 min
πŸ“• Buy this interview preparation book: 155 Wall Street Quant questions & answers β€” PDF + EPUB for $5

All 155 Wall Street Quant questions Β· All topics