Generate Two Random Variables by Using Only One Random Variable

767 Views Asked by At

I have the following question asked in an interview: how can we use one generated random variable from uniform $U(0, 1)$ to generate two random variables from the same distribution $U(0, 1)$. My initial thoughts were to do some decomposition, say $x = f(x_1, x_2)$ where $x$ is from $U(0, 1)$ but in generally I was like headless on this decomposition. I am not sure how can we do this.

1

There are 1 best solutions below

1
On BEST ANSWER

There is a neat link between the uniform distribution and an infinite sequence of independent fair coin flips.

Sketch of one solution to the question that uses the above neat fact:

  • Generate $x \sim U(0,1)$.
  • Write $x$ in binary: $(0.x_1 x_2 x_3 \cdots)_2$ and use the above link to recognize that $x_1, x_2, x_3, \ldots$ is a sequence of independent $\text{Bernoulli}(1/2)$ random variables.
  • Use the bits of this binary representation to create two new numbers $x' := (0.x_1 x_3 x_5 \cdots)_2$ and $x'' = (0.x_2 x_4 x_6 \cdots)$. Note that $x'$ and $x''$ are independent.
  • Use the link again to recognize that $x'$ and $x''$ are each distributed according to $U(0,1)$.

As mentioned in the comments, if the two generated random variables need not be independent, you can instead simply return $x \sim U(0,1)$ and $y := 1-x$. Or even $x \sim U(0,1)$ and $y:=x$.