Generic method
- Generate $U \sim \mathrm{Uniform}(0,1)$.
- Return $F^{-1}(U)$.
So, in step 1, $U$ has domain/support as $[0,1]$, so it is possible that $U=0$ or $U=1$, but $F^{-1}(0)=-\infty$. Should I reject the value $U=0$ and $U=1$ before applying step 2?
For example, discrete distribution sampling: $X$ takes on values $x_1, x_2, x_3$ with probability $p_1,p_2,p_3$
- Generate $U \sim \mathrm{Uniform}(0,1)$.
- Find the smallest $k$ such that $F(x_k)\geq U$ ($F$ is the CDF).
However, if $U=0$, and $p_1=0$, $k$ would be $1$. It could generate $x_1$ though its probability $p_1=0$. Is it acceptable?