# Sum of 3 uniform random variables is a constant

Give a construction of three random variables $X,Y,Z$ that are each uniform on $(0,1)$ but $X+Y+Z$ is a constant.

Is the following argument correct? We first consider every number in $(0,1)$ in ternary and for the $n$-th digit, randomly assign $0,1,2$ to $X, Y, Z$, such that all $n$-th digits are different. This means each random variable is uniformly distributed since each of it's digits has a 1/3 chance for each $\{0,1,2 \}$ To rigorize, you can show that $P(X\leq a) = a$ where $a = k/3^n$ and $n,k$ are positive integers.

So this extends to $P(X\leq r) = r, r\in \mathbb{Q}\cap (0,1)$ because we can find a decreasing sequence $a_j = \frac{k_j}{3^{n_j}}$ s.t $a_j\downarrow r$. Do I need to justify this step more? And then from here we extend it to reals in the same way. We use decreasing sequences because the CDF is right continuous. This shows that $X$ is uniform and similarly $Y$ and $Z$ are uniform on $(0,1)$ They add up to a constant since the digit-wise sum is just $0+1+2$ for each place.

• The constant should be $E[X+Y+Z]=1.5$, but this appears not to be the case for your construction.
– Dean
Jan 4, 2018 at 22:14
• I totally missed using expectations to find the actual constant! However, my construction does give that constant because in base three you would get a sum of $1.\overline{1}$, which is $1.5$ in base 10.
– iYOA
Jan 4, 2018 at 22:28
• @iYOA I think your construction is valid
– E-A
Jan 4, 2018 at 23:41
• Oh whoops, I misread the question: I thought your arithmetic was mod 1 and it isn't. I take it all back. I've deleted my previous comments. Jan 5, 2018 at 0:01
• Your construction works, OP. Jan 5, 2018 at 8:02

## 1 Answer

I think this construction is a little bit easier: Let $X$ be uniform on (0,1) and define

$$Y = \begin{cases}X+\frac 12, \quad X<\frac 12, \\ X- \frac 12, \quad X \geq \frac 12, \end{cases}$$ and

$$Z = \frac 32 - (X+Y).$$ Then clearly, $X+Y+Z = \frac 32$ and it remains to show that $Y$ and $Z$ are uniform on $(0,1)$.

A simple calculation shows that for $y \in [0, \frac 12)$ $$\Bbb{P}(Y \leq y) = \Bbb{P}\biggl(X \in \Big[\frac 12, \ y+ \frac 12\Bigr]\biggr) =y,$$ and similarly for $y \in [\frac 12 , 1]$ $$\Bbb{P}(Y \leq y) = \Bbb{P}\Bigl(X \geq \frac 12\Bigr) +\Bbb{P}\Bigl(X \leq y - \frac 12 \Bigr) =y,$$ so $Y$ is also uniform on $[0,1]$.

Finaly note that

$$Z = \frac 32 - (X+Y) = \begin{cases}-2X+ 1, \quad X<\frac 12, \\ -2X + 2, \quad X \geq \frac 12, \end{cases}$$ and we can similarly one can show that $Z$ has a uniform distribution on $(0, 1)$.

• Can this procedure be generalized to $N$ uniform random variables adding up to 1? Sep 2, 2022 at 17:14
• Well it is easy for $N = 2$ by simply choosing $Y = 1 - X$. For even $N$ we can pick pairs of uniform variables as in the case $N = 2$ such that each pair adds up to a constant and consequently the sum of all is also constant. For odd $N$ we can proceed similarly by construction one triple as in the case $N = 3$ and pairs as in the case of even $N$. Sep 3, 2022 at 12:39
• But in this way the individual random numbers won't stay in the $[0,1]$ range. For example lets say I want to generate 4 uniform random number in $[0,1]$ range and I follow the steps by generating 2 pairs and then dividing the all the random numbers by 2 so that their they all add up to 1 then this division by 2 will constraint all the random numbers to belong from $[0,1/2]$ not from $[0,1]$. Sep 4, 2022 at 6:07
• Also would it be possible for you to layout the algorithm when $X+Y+Z = 1$ instead of $3/2$ ? And $X,\,Y,\,Z\in\{0,1\}$. Sep 4, 2022 at 6:08
• The goal is to define uniform random variables on 0,1 such that their sum is constant. For $N=4$ you can pick two independent uniform random variables $U$ and $V$ and then define $X_1 = U, X_2 = 1-U, X_3 = V, X_4 =1 - V$. This way all $X_i$ are uniform on 0,1 and $X_1 + X_2 + X_3 + X_4 =2$. As you see all random variables stay in 0,1. Sep 4, 2022 at 12:40