# Can we sample from both pdf and cdf?

my question is quite generic. I am currently studying the algorithms calculating random numbers from distributions:

In inverse transform method we get the cumulative distribution function in the end and take the random variable from there. Whereas in rejection method, we are working directly with pdf. I got a little bit confused if we normally sample from cdf , since I have never come across it before.

I know what the cdf and pdf are and that they are tightly linked.

Hopefully, someone can clarify it to me if sampling from cdf is a common approach.

• There are a very large number of ways to sample from a distribution. Many do not need mathematical representations of the PDF or the CDF. It's difficult to use the CDF directly, but its inverse -- the quantile function -- gives perhaps the simplest, most direct method of sampling provided the quantile function can be computed. For more about this particular method see stats.stackexchange.com/search?q=inverse+transform+sampling.
– whuber
Commented Nov 12, 2020 at 17:12
• Theoretically one can simulate from any function identifying the distribution, e.g., pdf, cdf, mgf, quantile function, characteristic function... Commented Nov 12, 2020 at 17:26