Understanding Rejection Sampling method

A visual representation in R

Valentina Alto
Analytics Vidhya
Published in
5 min readSep 22, 2019

--

Rejection sampling is a computational technique whose aim is generating random numbers from a target probability distribution f(x). It is related to the general field of Monte Carlo methods, whose core is generating repeated random sampling to make a numerical estimation of unknown parameters.

Some words about Randomness

One might ask why a random variable with probability density f(x) cannot be easily generated by a computer algorithm. Well, the fact is that those latter are deterministic by nature, hence it is unfeasible to pretend randomness from them. Indeed, computer algorithms generate so-called pseudo-random numbers: those algorithms pick them from a ‘list of numbers’ which is huge, but ordered, in the same way, every time. Hence, the source of randomness is the starting point. You can easily visualize it if, when creating random numbers with any software (here, I’ll use R), you specify the starting point (called ‘seed’):

--

--

Valentina Alto
Analytics Vidhya

Data&AI Specialist at @Microsoft | MSc in Data Science | AI, Machine Learning and Running enthusiast