Generation of random variable from a complicated CDF

520 Views Asked by At

Suppose I am given a CDF of a distribution, given by $F(x) ∝ \int_0^1 x^y e^{-y} dy.$

Here,'x' ranges from 0 to 1. How do I generate a random variable from this distribution?

1

There are 1 best solutions below

1
On BEST ANSWER

In general, to sample from a random variable $X$ with CDF $F$, you introduce the "quantile function" $Q$. This is formally defined as

$$Q(y)=\inf \{ x : F(x) \geq y \}.$$

When $F$ is invertible, this is its inverse. When $F$ is not invertible, it is the "right generalization", in the sense that it correctly accounts for regions where $F$ is horizontal and for jumps in $F$.

Given the function $Q$, you generate a random variable $U$ which is uniform on $(0,1)$; then it turns out that $Q(U)$ has the same distribution as $X$. This is sometimes called the probability integral transformation.

So in your case, you must generate random numbers $U$. You will get $U=u$ for some $u \in [0,1]$, and you must then solve the equation

$$\frac{\int_0^1 x^y e^{-y} dy}{\int_0^1 e^{-y} dy} = u$$

for $x$. Then this equation will have a unique solution for any $u \in (0,1)$. This solution will be your randomly chosen value of $X$. These integrals can be done analytically, but you will have to solve the resulting equation numerically.