inverse-transform method let be random variable with cumulative distribution function (cdff let - denote the inverse of and ( thenp[ - ( xp[ ( ) ( ( this leads to the following method to simulate random variable with cdf falgorithm inverse-transform method inputcumulative distribution function outputrandom variable distributed according to generate from ( - ( return the inverse-transform method works both for continuous and discrete distributions after importing numpy as npsimulating numbers according to probabilities pk- can be done via np min(np where(np cumsum(pnp random rand()))where is the vector of the probabilities example (example (cont )one remaining issue in example was how to simulate the radius when we only know its density fr (rr - / we can use the inverse-transform method for thisbut first we need to determine its cdf the cdf of isby integration of the pdf fr ( and its inverse is found by solving fr (rin terms of rgiving fr- ( - ln( ) ( thus has the same distribution as - ln( )with ( since also has ( distributionr has also the same distribution as - ln acceptance-rejection method the acceptance-rejection method is used to sample from "difficultprobability density function (pdff (xby generating instead from an "easypdf (xsatisfying ( (xfor some constant (for examplevia the inverse-transform method)and then accepting or rejecting the drawn sample with certain probability algorithm gives the pseudo-code the idea of the algorithm is to generate uniformly point (xyunder the graph of the function cgby first drawing and then ( cg( )if this point lies under the graph of then we accept as sample from otherwisewe try again the efficiency of the acceptance-rejection method is usually expressed in terms of the probability of acceptancewhich is / every cdf has unique inverse function defined by - (uinf{ (xuiffor each uthe equation (xu has unique solution xthis definition coincides with the usual interpretation of the inverse function