Acceptance-Rejection Method

This is a rather simple and appealing method after von Neumann. Assume that we are looking at an interval \( x\in [a,b] \), this being the domain of the PDF \( p(x) \). Suppose also that the largest value our distribution function takes in this interval is \( M \), that is $$ \begin{equation*} p(x) \le M \hspace{1cm} x\in [a,b]. \end{equation*} $$ Then we generate a random number \( x \) from the uniform distribution for \( x\in [a,b] \) and a corresponding number \( s \) for the uniform distribution between \( [0,M] \). If $$ \begin{equation*} p(x) \ge s, \end{equation*} $$ we accept the new value of \( x \), else we generate again two new random numbers \( x \) and \( s \) and perform the test in the latter equation again.