Generating correlated discrete random variables

599 Views Asked by At

I would like to generate two correlated random variables $X$ and $Y$ with correlation coefficient $c \in [0,1]$.

$X$ and $Y$ have the same following distribution:

$P(X=1) = p$ and $P(X=-1)=1-p$ where $p \in [0,1]$,

One idea I had was to generate X and then I tried to generate Y with $Y = ZX$ where $Z$ is a r.v. with values in ${-1,1}$. But I am not sure it is possible to choose $Z$ to satisfy what we need.

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

First, let us transform both variables that we need to generate into pair of Bernoulli distributed by adding $1$ and halving both values after this: $$ \hat X=\frac{X+1}{2}, \quad \hat Y=\frac{Y+1}{2}. $$ We will generate $\hat X, \hat Y$ and after that get $(X,Y)=(2\hat X-1,2\hat Y-1)$.

New variables $\hat X$, $\hat Y$ should have marginal distributions $P\left(\hat X=1\right)=p$, $P\left(\hat X=0\right)=1-p$, and the same for $\hat Y$. And the correlation coefficient $c=r(X,Y)=r\left(\hat X,\,\hat Y\right)$ does not change after the same linear transformation.

Let us find Bernoulli r.v. $\hat Z$ which is independent of $\hat X$, $P\left(\hat Z=1\right)=\alpha$ and $r\left(\hat X,\hat Z\hat X\right)=c$. And after that we can take $\hat Y=\hat Z\hat X$. Note that $$P\left(\hat Z\hat X=1\right)=\alpha p, \quad P\left(\hat Z\hat X=0\right)=1-\alpha p,$$ $$Var\left[\hat Z\hat X\right]=\alpha p(1-\alpha p), \quad Var\left[\hat X\right]=p(1-p).$$

$$c=r\left(\hat X,\hat Z\hat X\right)=\dfrac{E\left[\hat X\cdot \hat Z \hat X\right]-E\left[\hat X\right]E\left[\hat Z\hat X\right]}{\sqrt{Var\left[\hat X\right]Var\left[\hat X \hat Z\right]}} = \dfrac{\alpha p-\alpha p^2}{\sqrt{p(1-p)\alpha p(1-\alpha p)}} = \dfrac{\sqrt{\alpha (1-p)}}{\sqrt{1-\alpha p}}. $$ Then $c^2(1-\alpha p) = \alpha(1-p)$ and $\alpha=\dfrac{c^2}{pc^2+1-p}$.

Repeat the recipe. Generate $\hat X$ with Benoulli distribution with parameter $p$, independently generate $\hat Z$ with Benoulli distribution with parameter $\alpha=\dfrac{c^2}{pc^2+1-p}$, take $X=2\hat X-1$, $Y=2(\hat Z\hat X)-1$.