How do you build a variable with a chosen correlation to X?

Statistics
Medium
A statistics puzzle about covariance, variance and correlation.
Published

November 16, 2026

NoteQuestion

\(X\) and \(\varepsilon\) are independent random variables, each with mean 0 and variance 1. For a given correlation \(\rho\) from −1 to 1, find numbers \(a\) and \(b\) so that \(Y = aX + b\varepsilon\) has variance 1 and correlation \(\rho\) with \(X\).

Try it first, then open the solution.

One answer is \(a = \rho\) and \(b = \sqrt{1 - \rho^2}\), so \(Y = \rho X + \sqrt{1 - \rho^2}\,\varepsilon\).

The correlation condition fixes \(a\), and the variance condition then fixes \(b\).

Independence gives \(\operatorname{Cov}(X, \varepsilon) = 0\), and \(\operatorname{Var}(X) = 1\). The covariance of \(Y\) with \(X\) is

\[\begin{aligned} \operatorname{Cov}(Y, X) &= a \operatorname{Var}(X) + b \operatorname{Cov}(\varepsilon, X) \\ &= a \times 1 + b \times 0 = a. \end{aligned} \tag{1}\]

The question requires \(\operatorname{Var}(Y) = 1\), so both variances are 1 and the correlation equals the covariance:

\[\begin{aligned} \rho = \operatorname{Corr}(Y, X) &= \frac{\operatorname{Cov}(Y, X)}{\sqrt{\operatorname{Var}(Y) \operatorname{Var}(X)}} \\ &= \frac{a}{\sqrt{1 \times 1}} = a. \end{aligned} \tag{2}\]

Multiplying a variable by \(b\) multiplies its variance by \(b^2\), and independence removes the cross term, so the variance condition fixes \(b^2\):

\[\begin{aligned} 1 = \operatorname{Var}(Y) &= \rho^2 \times 1 + b^2 \times 1 + 2 \rho b \times 0 \\ &= \rho^2 + b^2. \end{aligned} \tag{3}\]

Solving (3) with the nonnegative root gives

\[b = \sqrt{1 - \rho^2}, \quad Y = \rho X + \sqrt{1 - \rho^2}\,\varepsilon. \tag{4}\]

At \(\rho = 0\), formula (4) gives \(Y = \varepsilon\), and at \(\rho = 1\) it gives \(Y = X\). With \(\rho = 0.8\), for example,

\[\begin{aligned} b &= \sqrt{1 - 0.8^2} = 0.6, \\ \operatorname{Var}(Y) &= 0.8^2 + 0.6^2 = 0.64 + 0.36 = 1. \end{aligned} \tag{5}\]

So \(X\) gives 0.64 of the variance of \(Y\), and \(\varepsilon\) gives the other 0.36.

The same construction builds correlated returns for a simulation, by mixing two independent standard normal draws with weights \(\rho\) and \(\sqrt{1 - \rho^2}\).

Three wrong answers are common. Each takes \(a = \rho\) and fails at \(\rho = 0.8\):

\(b\) The slip
0 leaves out \(\varepsilon\), so \(Y\) moves exactly with \(X\), with \(\operatorname{Var}(Y) = 0.64\) and \(\operatorname{Corr}(Y, X) = 1\)
1 keeps all of \(\varepsilon\), so \(\operatorname{Var}(Y) = 0.64 + 1 = 1.64\) and \(\operatorname{Corr}(Y, X) = 0.8/\sqrt{1.64} = 0.62\)
\(1 - \rho\) makes the weights add to 1 in place of their squares, so \(\operatorname{Var}(Y) = 0.64 + 0.04 = 0.68\) and \(\operatorname{Corr}(Y, X) = 0.8/\sqrt{0.68} = 0.97\)
import numpy as np

rho = 0.8
x, e = np.random.default_rng(1).standard_normal((2, 1_000_000))
y = rho * x + np.sqrt(1 - rho**2) * e
print(round(y.var(), 2), round(np.corrcoef(x, y)[0, 1], 2))
1.0 0.8