Construct random variable from uniform distribution

917 Views Asked by At

I am trying to do this problem:

Suppose $ U$ is a random variable with distribution $\mathcal U(0,1)$. Find a function $g$ such that $g(U)$ has distribution:

i)$\mathcal E(1)$

ii) $Bi(5,\dfrac{1}{3})$

iii) a discrete random variable with range $R_X=(x_n)_{n \in \mathbb N}$ and respective puntual probabilities $(p_n)_{n \in \mathbb N}$.

I have no idea how to solve this, is there a general method to construct a random variable from one that has uniform distribution? I would appreciate some help with the exercise. Thanks in advance

1

There are 1 best solutions below

0
On

Comment for (i). The required function is $g(U) = -log_e(1 - U).$ The following R code uses the inverse CDF method to generate 10,000 realizations of $X \sim Exp(rate = 1),$ and then uses the Kolmogorov-Smirnov goodness-of-fit test to see whether the sample does indeed match the desired distribution.

 x = -log(1-runif(10^4))
 ks.test(x, "pexp" ,1)

      One-sample Kolmogorov-Smirnov test

 data:  x 
 D = 0.0116, p-value = 0.1326     # P-val > .05 suggests agreement with Exp(1).
 alternative hypothesis: two.sided 

Notes: (a) The transformation $g(U) = -log(U)$ works as well because $U \sim Unif(0,1)$ is equivalent to $1 - U \sim Unif(0,1).$ But the function I used is precisely the inverse of the CDF of $Exp(1).\;$ (b) the K-S test would not work for discrete cases (ii) and (iii), but there are other GOF tests, which you may or may not be interested to investigate$\;$ (c) In simulation, pseudo-random generators usually supply sequences of essentially independent observations from $Unif(0,1)$ and then some method such as the inverse transformation method is used to sample from other distributions.$\;$ (d) Before (ii), you might first try understanding the inverse CDF of some simpler distribution such as $Binom(2, 1/2).$

Graphs of the CDF and inverse CDF of $Binom(2, 1/2)$ are shown below. In each case only the horizontal segments 'matter'.

enter image description here