Posted on

Rejection Sampling

Rejection sampling is a simple algorithm to sample from an arbitrary distribution that is hard to sample from directly. The idea is to accept and reject the samples from another distribution which is easy to sample from. Suppose that:

1- is the target distribution that can be any arbitrary function of , such that:

  • and

2- is another distribution which is easy to sample from and also for all values of , there exists a constant satisfying .

3- is the uniform distribution such that:

Now suppose that we have one sample generator for distribution (which was easy to do the sampling ) and one for the uniform distribution .

In each step, first we generate a sample from the distribution and we call it , also we get another sample from the uniform distribution and we call it . Now if we accept this sample and otherwise it should be rejected.

image

We want to show that by continuing this algorithm the emprical distribution for the accepted samples is equal to the desired distribution.

First it’s obvious that we are looking for which is equal to . By using Bayes rule we have:

Now we can evaluate each term separately.

1- is the probability that the sample is accepted which is equal to

2- is the distribution used for generating , so we have

3-

And the proof is complete: