algorithm acceptance-rejection method inputpdf and constant such that cg(xf (xfor all outputrandom variable distributed according to pdf found false while not found do generate from generate from ( independently of ucg( if (xthen found true return example (simulating gamma random variablessimulating random variables from gamma(aldistribution is generally done via the acceptance-rejection method considerfor examplethe gamma distribution with and its pdf la xa- -lx (ar where is the gamma function ( : - xa- dxa is depicted by the blue solid curve in figure ( figure the pdf of the exp( distribution multiplied by dominates the pdf of the gamma( distribution this pdf happens to lie completely under the graph of cg( )where and ( exp(- ) is the pdf of the exponential distribution exp( hencewe can simulate from this particular gamma distribution by accepting or rejecting sample from the exp( distribution according to step of algorithm simulating from the exp( distribution can be done via the inverse-transform methodsimulate ( and return ln( )/ the following python code implements algorithm for this example