BASIC IDEA AND ALGORITHM
Assume now that a complicated p.d.f. p(x) is given in the range [0,1]. How can random numbers R be distributed according to p(x), when p(x) cannot be integrated analytically. Well, of course, the reasoning before could be applied by tabulating the (normalised) integral over p(x), P(x), in sufficiently small bins and by just interpolating in this look-up table of the integral. This is not always a very good option, after all, the two closest entries with P(x1)< R < P(x2) have to be found and x must then be reconstructed through interpolation between x1 and x2. This may be quite time-consuming, in more than one dimension such an operation easily becomes a nightmare in terms of CPU time.EXAMPLES AND THE ROLE OF THE MAXIMUM
This algorithm and the effect of playing with the (estimated) maximum can be tried out here. Clearly, the assumption of a too large maximum of p(x) does not harm the shape of the functions, since it cancels out when looking at ratios of bins at different x. A too large maximum just spoils the efficiency (performance) of the unweighting because in this case more trials than neccessary have to be done. In the opposite case, however, i.e. with a too small maximum, the shape of the function becomes distorted, since in all regions of x with p(x) larger than the maximum the trial random number is taken with 100% probability.