[Math] Marginal distribution for correlated uniform variables

correlationprobabilityprobability distributionsprobability theorystatistics

Question

Let $X$ and $Y$ be two uniformly distributed random variables with bounds $x_\text{low}$, $x_\text{up}$, $y_\text{low}$ and $y_\text{up}.$ $X$ and $Y$ are correlated with a correlation coefficient of $R$.

Given an observed outcome $x$ from the variable $X$ and given the correlation coefficient $R$, how can one calculate the probability of a particular outcome $y$ from variable $Y$. In other words, how can one calculate

$$P(Y=y \mid X=x, R) = \text{?}$$

Extreme cases

The extreme cases are easy. If $R=0$ ($X$ and $Y$ are independent), then

$$P(Y=y \mid X=x, R) = \frac 1 {Y_\text{up} – Y_\text{low}}$$

If $R = 1$, then

$$P(Y=y \mid X=x, R) =
\begin{cases}
1, & \text{if} \space y = \frac{x – x_\text{low}}{x_\text{up} – x_\text{low}} \\
0, & \text{if} \space y ≠ \frac{x – x_\text{low}}{x_\text{up} – x_\text{low}}
\end{cases}$$


Goal

In case it is of interest, my goal when asking this question is to write a short algorithm that sample points from this bivariate uniform distribution with specified correlation coefficient.

Best Answer

The most straightforward (but not the only) way to get a pair of random variables correlated in the way that you want is to take $X \sim \operatorname{Uniform}(x_{\text{low}},x_{\text{up}})$ and define $Y$ as follows:

  1. When $R \ge 0$, define $$Y = \begin{cases}\frac{X-x_{\text{low}}}{x_{\text{up}}-x_{\text{low}}}\cdot (y_{\text{up}}-y_{\text{low}}) + y_{\text{low}} & \text{w.p. }R \\ \operatorname{Uniform}(y_{\text{low}},y_{\text{up}}) & \text{else.}\end{cases}$$
  2. When $R < 0$, define $$Y = \begin{cases}\frac{X-x_{\text{low}}}{x_{\text{up}}-x_{\text{low}}}\cdot (y_{\text{low}}-y_{\text{up}}) + y_{\text{up}} & \text{w.p. }|R| \\ \operatorname{Uniform}(y_{\text{low}},y_{\text{up}}) & \text{else.}\end{cases}$$

In other words, $Y$ is a mixture of a random variable independent from $X$, and a random variable perfectly linearly correlated with $X$ (either positively or negatively, depending on which you want).