# Correlation between Normal variate generations

I have a function that returns normal distributed random numbers (let's call a single number X) when I pass the parameters mean and standard deviation. What I want is another function that generates normal distributed values (another, second mean / standard deviation) that are correlated to X with a given correlation coefficient (for example 0.8). How can I do this only with scalar functions (no vector / no matrix)?

If you have $X_1 \sim$ normal$(\mu_1, \sigma^2_1)$ then you could consider letting $X_2 := a X_1 + b + \epsilon$ where $\epsilon \sim$ normal$(0, \sigma^2_\epsilon)$ and is independent of $X_1$. Then $X_2 \sim$ normal$(\mu_2, \sigma^2_2)$ and $\text{Corr}(X_1, X_2) = \rho$ where
If $\mu_2, \sigma^2_2$ and $\rho$ are fixed then you have three equations and three free parameters $a, b$ and $\sigma^2_\epsilon$, at which point you only need to do some algebra to find the right transformation.
• I don't believe it has a name. Just consider that correlation measures linear relationships between random variables, so if you already have one it's natural to try applying a linear transformation with some noise to get the other. After that point the formulas above can be derived by hand. However, bear in mind we were assuming everything is normal here. This won't work in general since $X_2$ need not belong to the right family after the transformation. – dsaxton Feb 17 '16 at 16:36
• We already have the standard deviations for $X_1$ and $X_2$, so we only need to find their covariance which is $\text{Cov}(X_1, aX_1 + b + \epsilon) = a \text{Cov}(X_1, X_1) = a \sigma_1^2$ where we've used linearity of covariance and independence. If you divide this by the product of the standard deviations you get the formula for $\rho$. – dsaxton Feb 17 '16 at 23:00
• So, I get it. But the product of standard deviations means that there is a $\sigma_1$ missing in the denominator, isn't it? – ScientiaEtVeritas Feb 17 '16 at 23:50