Skip to main content
edited tags
Link
Tim
  • 141.2k
  • 26
  • 270
  • 512
Source Link
Prab
  • 21
  • 2

Sampling from a distribution function $g_{x}$ that will follow $f_{x}$

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.