# Marginal distribution for correlated uniform variables

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.

• Correlation of $1$ means a perfectly positive linear relationship. But specifying the correlation only does not uniquely characterize the joint distribution (and thus the conditional distribution also). Also correlation of $0$ does not mean they are independent. – BGM May 13 '17 at 4:26
• @BGM If we assume any potential relationship between the two variables is linear, is the correlation coefficient then sufficient at describing this relationship? Thanks for feedback – Remi.b May 13 '17 at 4:40
• @Remi.b : If by "linear" you mean the pair lies on a straight line, then that, in conjunction with the fact that each random variable is uniformly distributed, implies the correlation is either $1$, $-1.$ If you mean the graph of the conditional expected of one variable, given the value of the other, lies on a straight line, then I think that's not enough to determine the conditional distribution. – Michael Hardy May 13 '17 at 5:05
• @MichaelHardy Yes, I meant the expected value of one variable given the outcome of the other falls on a straight line. Do you have suggestion on how I could go to make my question fully defined and "answerable"? As explained in the post, my goal is to create bivariate uniform distribution (which I'd code in java) just like the R package mvtnorm is doing for the normal distribution (and could be extended to the uniform distribution with copulas). – Remi.b May 13 '17 at 5:11

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).

if I am guessing correctly (from the comments bewlow your question) you want to simulate something like a "bivariate uniform distribution" and your inspiration arises from the bivariate normal distribution. In my opinion your goal is not (yet) well defined. To make my point clear I will first summarize the bivariate normal distribution.

Bivariate normal distribution A two dimensional random vector $(X, Y)$ is said to have a bivariate normal distribution if its joint pdf is given by ...(see here). If $(X, Y)$ is a bivariate random vector then we can conclude the following:

1. $X$ has a uniform normal distribution and so does $Y$.
2. The joint distribution of $X$ and $Y$ is fully determined by the marginal distributions of $X$ and $Y$ and their correlation coefficient $R$. In fact the corresponding copula is the Gauss-Copula with parameter $R$.

Why am I telling you something that probably already know? Because the logic from above in general does not translate to other distibutions. McNeil, Frey and Embrechts describe two fallacies in their book quantitative risk management (see here):

• Fallacy 1: The marginal distributions and pairwise correlations of a random vector determine its joint distribution.
• Fallacy 2: For given univariate distributions $F_X$ and $F_Y$ and any correlation value $R$ in $[−1, 1]$ it is always possible to construct a joint distribution $F$ with margins $F_X$ and $F_Y$ and correlation $R$.

They explain more detailed why the results from the normal distribution are in general not valid for other distributions.

• First you have to be aware that specifying the distribution of $X$ and $Y$ as uniform and specifying the correlation of $X$ and $Y$ you do not specify their joint distribution (see Falacy 1). The joint distribution is only specified if have a corresponding joint distribution function $F_{X,Y}$.
• Second (motivated by fallacy 2), you should keep in mind that for fixed $x_{low}, x_{up}, y_{low}, y_{up}$ and $R$ their might not even exist a joint distribution $F_{X,Y}$.
• Third, for me, the words "joint bivariate uniform distribution" mean a distribution which samples uniformly from any bounded subspace in $R^2$. In your case this would be a rectangle definded by its corners $(x_{low}, y_{low}), (x_{low}, y_{up}), (x_{up}, y_{low}), (x_{up}, y_{up})$. This would (for me) imply that $X$ and $Y$ are independent from each other. This is just a wording issue.
So to make your problem better defined you first have to think about a good definition of joint uniform distribution. The correlation $R$ in your case is not enough to do the job.