Simulation using inverse function
Suppose our desired density function is $f$ in an open interval $I$. Then the distribution function $F(x) = \int_{-\infty}^{x} f(y) dy$ is an increasing map from $I$ to $(0,1)$. Let the quantile function be $$ \begin{align*} G(u) = \inf\sb{x\in\R}{u\leq F(x)}. \end{align*} $$ (When $f$ is positive everywhere, $G=F\inv$.) Note that for all $x\in\R, u\in(0,1)$, $$ \begin{align*} G(u) \leq x \iff u \leq F(x). \end{align*} $$ Then when we have $U\sim U[0,1]$ and let $X=G(U)$, we have $$ \begin{align*} \prob(X\leq x) = \prob(G(U)\leq x) = \prob(U\leq F(x)) = F(x) \end{align*} $$ so $X$ has a distribution function $F_X$.