The most programming languages offer a (pseudo)random number generator that gives samples of a uniform distribution in the range of (0,1).
A common MC sampling technique is the inverse cumulative method that using the uniformly sampled r random number produces a sample of the pdf:
We will see an example to this in the next section.
A lot simpler, but a lot less effective method is when we chose a pdf that we can easily be sampled (it can simply be the uniform distribution and r is automatically a sample of it). Now let us write the integral like this:
let us choose Pi from q our estimate should be:
The new quantity arising is the weight of the particle.
The next section shows the sampling of the free flight distance.
The original document is available at http://549552.cz968.group/tiki-index.php?page=Sampling