# generating random samples with a PDF

I have the PDF of a distribution from which it is not possible to get a closed from for the CDF or inverse CDF. Is there a technique that would allow me to generate samples from this distribution using the PDF?

• It depends. The normal density does not have a closed-form expression for the CDF or the inverse CDF but samples can nonetheless be generated via the Box-Muller method (among others). So, does your pdf have any nice properties that can be exploited? – Dilip Sarwate Jul 9 '14 at 17:06

Here is a suggestion for the case where the density function is $0$ outside the interval $[a,b]$, and is bounded by $c$ on $[a,b]$. Use a random number generator to generate random points om the rectangle with base $[a,b]$ and height $c$. If the pdf is $f(x)$, discard all points $(x,y)$ such that $y\gt f(x)$. For each point you keep, record $x$.