Accept reject sampling for univariate pdf

45 Views Asked by At

I am working on generating near uniform samples from an arbitrary univariate truncated pdf (from $[x_1, x_2]$) using Python, the form of the unnormalized pdf is $\sqrt{P(x)}$, where P(x) is a polynomial of finite degree.

I want to try using the Accept-Reject method and Inverse-Transform method for this, but my doubts are as following:

  1. For accept reject sampling, which proposal density should I choose, also is there an efficient way of calculating the maximum value of $P(x)$ for using the Accept Reject method.
  2. For the inverse transform method, how do I calculate the CDF and after that compute it's inverse?