2
$\begingroup$

I am using acceptance-rejection sampling to sample random variable $x$ according to distribution $f(x)$. The steps I followed are

  1. First generated uniformly distributed random variable $x$ from 0 to $x_{max}$
  2. Generated a second random number $u$ between 0 and $f_{max}$.
  3. Then checked the condition if $u < f(x)$, If this condition is satisfied then I accept $x$ otherwise reject and repeat the above two steps.

In the 1st step I have generated $x$ that follows a uniform distribution. Is it possible to sample random variable $x$ that already has distribution which is not uniform ? Means $x$ already has a distribution function $g(x)$ but I want to sample those $x$ who will follow my desired distribution function $f(x)$.

Example: The initial random variable $x$ has a distribution function as shown in the figure (which is not uniform). enter image description here

My target distribution looks like the figure below. enter image description here

Now Is it possible to sample $x$ from the first figure that will follow the target distribution function (second figure)? If yes, then how to do this? Should I use any other method than acceptance-rejection sampling.

$\endgroup$

1 Answer 1

4
$\begingroup$

Sure you can. For example, you can use the independent variant of the Metropolis-Hasting algorithm.

  1. Generate $x'$ from the distribution $g$,
  2. Take

$$ x_{t+1} = \cases{ x' \quad \text{with probability} \; \min\Big( \frac{f(x') g(x_t)}{f(x_t) g(x')}, \, 1\Big) \\ x_t \quad \text{otherwise} } $$

See Christian P. Robert and George Casella Monte Carlo Statistical Methods, p. 276. Notice however that this would not work if $f$ and $g$ have different domains and would not be very efficient if the two distributions are very different from each other.

There may be even more efficient algorithms (see ) if you wouldn't insist on generating the samples independently from $g$.

$\endgroup$
1
  • $\begingroup$ Independent Metropolis is very close to accept-reject, with a higher average acceptance probability, but producing a dependent sequence. A slightly different approach is to use the ratio of uniform method. $\endgroup$
    – Xi'an
    Commented Mar 24, 2023 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.