generating random samples with a PDF

252 Views Asked by At

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?

1

There are 1 best solutions below

2
On

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$.