I wish to numerically generate a random number from the distribution $$ P(x) = Ax^{-3/2}\exp(-B/x),\qquad A,B,x>0 $$

What would be the easiest way of achieving this?

Inverse transform sampling does not seem appropriate since the above $P(x)$ does not have an analytical cumulative distribution function.

Rejection sampling requires a second distribution to draw samples from, but I don't know what known distribution would be efficient for this purpose.


If $X$ is distributed according to your density, then $\frac{2B}{X}$ has density proportional to $x^{-\tfrac{1}{2}} e^{-x/2}$. This is the density of a Chi-squared distribution with one degree of freedom, i.e. $X \stackrel{d}{=} \frac{2B}{N^2}$, where $N$ is a standard normal random variable.

  • $\begingroup$ It works. Very neat solution, thanks. $\endgroup$ – lemon Dec 12 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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