How can one create random numbers with special correlations?

970 Views Asked by At

Is it possible to create uniformly distributed real pseudo random numbers
$x_1,x_2$, and $y_1,y_2,y_3\in$ $[0,1]$, subject to the following constraints:

$$x_1^2+x_2^2=1$$

$$y_1^2+y_2^2+y_3^2=1$$

I tried to use sines and cosines but that does not work; the conventional approach in creating correlated random numbers with a given Pearson correlation coefficient (matrix) via Cholesky decomposition does not seem to suit this situation.

How can one implement it? Is that feasible?

3

There are 3 best solutions below

4
On BEST ANSWER

If $x_1^2+x_2^2=1$ and $x_1$ is uniformly distributed over $[0,1]$ then the distribution of $x_2^2=1-x_1^2$ is determined. It is not the same distribution of $z^2$ where $z$ is uniformly distributed over $[0,1]$. So the answer to your "Is it possible..." is: no if it comes to two random numbers. I am not sure about three numbers.

4
On

As @drhab wrote, it's impossible for two variables. It is possible for three variables, though: an interesting fact is that if you choose a random point on a unit sphere in 3 dimensions (in such a way that it's uniformely distributed over the area), then its $x,y$ and $z$ coordinates are all uniformely distributed over $[-1,1]$. So if $y_1$ and $\phi$ are independent variables, uniformely distributed over $[0,1]$ and $[0,\pi/2]$, correspondingly, and you set $$ y_2 = \sqrt{1-y_1^2}\cos\phi;~~ y_3 = \sqrt{1-y_1^2}\sin\phi, $$ then $y_2$ and $y_3$ are uniformely distributed over $[0,1]$ as well.

4
On

In 2D, using polar coordinates $x_1=\cos 2\pi u,x_2=\sin 2\pi u$, where $u$ is uniform in $[0,1]$.

In 3D, using spherical coordinates $y_1=2\sqrt{v-v^2}\cos 2\pi u, y_2=2\sqrt{v-v^2}\sin 2\pi u, y_3=2v-1$, where $v$ s uniform in $[0,1]$.