# How to find correlation between two random variables?

What is the way to find a correlation between two variables, where $$X_1,X_2,X_3$$ are independent and random variable is a linear equation of these variables. Also, how to find an value of $$a_1$$, so that two variables are uncorrelated? For example if variables are given as $$X_1+2X_2$$ and $$3X_1+aX_2$$. Thanks for any advice!

We have $$X_1,X_2$$ and $$X_3$$ independent.

Let $$U=a_1X_1+a_2X_2+a_3X_3$$ and $$V=b_1X_1+b_2X_2+b_3X_3$$

$$Corr(U,V)=\frac{cov(U,V)}{\sqrt{var(U)var(V)}}=\frac{\sum_{k=1}^{3}{\sum_{j=1}^{3}{a_kb_jcov(X_k,X_j)}}}{\sqrt{cov(U,U)cov(V,V)}}$$

if $$k \ne j$$, $$cov(X_k,X_j)=0$$

$$Corr(U,V)=\frac{a_1 b_1var(X_1)+a_2 b_2var(X_2)+a_3b_3var(X_3)}{\sqrt{cov(U,U)cov(V,V)}}$$

$$cov(U,U)=a_1^2var(X_1)+a_2^2var(X_2)+a_3^2var(X_3)$$ $$cov(V,V)=b_1^2var(X_1)+b_2^2var(X_2)+b_3^2var(X_3)$$

Therefore,

$$Corr(U,V)=\frac{a_1 b_1var(X_1)+a_2 b_2var(X_2)+a_3b_3var(X_3)}{\sqrt{\left(a_1^2var(X_1)+a_2^2var(X_2)+a_3^2var(X_3)\right)\left(b_1^2var(X_1)+b_2^2var(X_2)+b_3^2var(X_3)\right)}}$$

Now, if you want the correlation between $$X_1+2X_2$$ and $$3X_1+aX_2$$ to be zero, in other words, their covariance should be nil:

$$0=cov(X_1+2X_2,3X_1+aX_2)=3cov(X_1,X_1)+2acov(X_2,X_2)=3var(X_1)+2avar(X_2)$$

because $$X_1$$ and $$X_2$$ are independent, we have $$cov(X_1,X_2)=0$$

You choose $$a=-\frac{3var(X_1)}{2 var(X_2)}$$

• ok, thank you. But how o find correlation itself? – user Jan 2 at 20:38
• you said it is uncorrelated. – Canardini Jan 2 at 20:39
• Yes, there are two questions: one is to find such $a$ that randm variables are uncorrelated but how do I calculate correlation between random variables? – user Jan 2 at 20:44
• Check the edit, you have both cases – Canardini Jan 2 at 20:54