<s>[INST] Finding a distribution with a given correlation Below is a problem that I made up and my attempt at a solution to it. I am hoping that somebody here can help me finish it. I believe there is a unique
answer to the problem.
Thanks,
Bob  
Problem:
Let $X$ and $Y$ be uniformly distributed independent variables on the interval $(-1,1)$. Let $K$ be
a real number. Let $Z = Y + KX$ such that the correlation of $X$ and $Z$ is $\frac{1}{2}$. Find $K$.
Answer:
If we select $K = 0$ then we get a correlation of $0$. If we select $K$ to be a very large number
then the correlation will be close to $1$.
\begin{align*}
\rho &= \frac{1}{2} \\
u_x &= 0 \\
u_y &= 0 \\
u_z &= u_y + K(u_y) = 0 + K(0) = 0 \\
\sigma_x^2 &= \frac{(1 - -1)^2}{12} = \frac{4}{12} \\
\sigma_x^2 &= \frac{1}{3} \\
\sigma_x &= \frac{1}{\sqrt{3}} \\
\sigma_y &= \frac{1}{\sqrt{3}} \\
\sigma^2_z &= \sigma^2_y + K^2 \sigma_x^2 + K(0) \\
\sigma^2_z &= \frac{1}{3} + K^2 \left( \frac{1}{3} \right) \\
\rho &= \frac{\sigma_x \sigma_z}{\sigma_{xz}} \\
\sigma_{xz} &= \frac{\sigma_x \sigma_z}{\rho} =
 \frac{ \left( \frac{1}{\sqrt{3}}  \right) \left( \frac{1}{3} + K^2 \left( \frac{1}{3} \right)  \right) }{\frac{1}{2} }\\
\sigma_{xz} &= \left( \frac{2}{\sqrt{3}}  \right) \left( \frac{1}{3} + K^2 \left( \frac{1}{3} \right)  \right) \\
\sigma_{xz} &= \left( \frac{2}{3 \sqrt{3}}  \right) \left( K^2 + 1 \right)  \\
\end{align*}
 [/INST] As you show, Pearson's $r$ should be a function of $k$. We will find that function and solve for
$r(k) = \frac{1}{2}$.
$r(A,B)$ may be calculated from the covariance $cov(A,B)$ and the standard deviations $\sigma_A$ and $\sigma_B$ as $\frac{cov(A,B)} { \sigma_A \sigma_B}$.
The covariance itself may be calculated as $E(AB) - E(A)E(B)$.
With $A$ and $B$ independent and each symmetric around $0$, the second term is $0$.
So with $Z = KX + Y$, we have $cov(X,Z) = E[X(kX+Y)] = E(KX^2) + E(XY)$.
Again, with $X$ and $Y$ independent and each symmetric around $0$, the second term is $0$.
$$ cov (X,Z) = E(KX^2) = KE(X^2) $$
The second moment $E(X^2)$ of a continuous uniform distribution $(a^2 + ab + b^2)/3$ where $a$ and $b$
are the bounds of the distribution. In this case, $(-1)^2 + (-1)*1 + 1^2 = 1 -1 + 1 = 1$.
$$ cov(X,Z) = K \frac{1}{3}  =  \frac{K}{3}$$

The variance $V(X)$ of a uniform distribution is $(b-a)^2/12$.
\begin{align*}
V(X) &= \frac{[1-(-1)]^2}{  12 } = \frac{2^2}{12} = \frac{1}{3} \\
V(Z) &= V(KX+Y) = K^2*V(X)*V(Y) = K^2V(X) + V(X) = (K^2+1)V(X) \\
V(Z) &= \frac{(K^2+1)}{3} \\
V(X)V(Z) &= \frac{K^2+1}{9} \\
\sigma(X)\sigma(Z) &= \sqrt{ \frac{K^2+1}{9} } = \frac{ \sqrt{K^2+1} }{ 3 }\\
r(X,Z) &= \frac{ \frac{K}{3}}{  \frac{\sqrt{K^2+1}}{3}}  = \frac{K}{ \sqrt{K^2+1)} } \\
\end{align*} 

So for $r = \frac{1}{2}$, $\frac{K}{\sqrt{K^2+1}} = \frac{1}{2}$.
$$ 2K = \sqrt{K^2+1} $$
We will square both sides, which will give two solutions for $K$, only one of which will be relevant.
\begin{align*}
4K^2 &= K^2 + 1 \\
3K^2 - 1 &= 0 \\
\end{align*}
using $a^2 - b^2 = (a+b)(a-b)$, we see $(\sqrt{3}K +1)(\sqrt{3}K - 1) = 0$.
$$ \sqrt{3}K = 1 \text{ OR } -1$$
Since we can see in the original problem K must be positive to yield a positive correlation, 
$\sqrt{3}K = 1$.
$$ k = \frac{1} {\sqrt{3}} $$
</s>