# How to create a covariance between two distributions?

I have two distributions $$A$$ and $$B$$ that are i.i.d.

I want to create two distributions $$A'$$ and $$B'$$, that have the "same distribution" as $$A$$ and $$B$$ (meaning the same probability distribution function), but are correlated (pearson correlation) with correlation $$\rho$$.

My first approach was to set $$A' = B' = (A+B)/2$$, but this works only for perfect correlation (or $$\rho = -1$$). Furthermore the distribution of $$A'$$ is not neccessarily equal to the distribution of $$A$$.

If the general case is to complicated, the problem I work on actually only requires $$A$$ to be uniform and not any given distribution.

## 1 Answer

This trick works for any $$\rho\in[0,1]$$: Flip a biased coin whose heads probability is $$\rho$$. If heads comes up, let $$(A',B') = (A,A)$$; otherwise let $$(A',B') = (A,B)$$.

If you want a negative $$\rho$$, and if $$A$$ and $$B$$ are to be uniform on $$[0,1]$$, flip a coin with heads probability $$|\rho|$$ and let $$(A',B') = (1-A,A)$$ if heads comes up and $$(A',B') = (A,B)$$ otherwise.