2
$\begingroup$

I have a probability distribution function that I don't have its analytical form (so I can't determine its CDF). How can I generate random numbers based on this distribution function? I'm looking for a way that is similar to that of using CDF.

$\endgroup$
  • $\begingroup$ What form do you have the pdf in? Can you evaluate the pdf at desired points? What’s the dimension? $\endgroup$ – Brian Borchers Apr 12 '18 at 4:06
  • $\begingroup$ Actually, we don't have its analytic form but we can evaluate its value wherever we want. It's one dimensional. $\endgroup$ – Pourya Vakilipourtakalou Apr 12 '18 at 21:12
2
$\begingroup$

Your goal is to obtain the inverse function.

Given the probability distribution $\rho(x)$ you are looking for the point $y$ such that the cumulative probability up to this point coincides with the result of a uniform distribution $U$ (you are converting a uniform distribution into your own distribution).

Therefore you have:

$$ \int_{-\infty}^y \rho(x)\,dx=U$$

The value $y$ can be obtained iteratively, for example, using Newton Raphson method:

$$y^{n+1}=y^n-\frac{\int_{-\infty}^{y^n} \rho(x)\,dx-U}{\rho(y^n)}$$

The resulting $y$ series will be arranged with a probability according to your distribution given the pair $(U,y)$ obtained from each uniform evaluation $U\rightarrow y$.

What is more, you must solve the integrals with numerical methods since you have no analytic expression for the density.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Actually, it wold take a lot of time to do this, I mean computationally it's not efficient since for evaluating the integral numerically, I need to do another MC integration which makes me face the same problem. $\endgroup$ – Pourya Vakilipourtakalou Apr 12 '18 at 21:13
  • $\begingroup$ If the dimension of $x$ is low, then evaluating the integral numerically is probably a good way to go. If not, then a Markov Chain Monte Carlo method is probably best. $\endgroup$ – Brian Borchers Apr 12 '18 at 21:46
1
$\begingroup$

That is exactly what the Monte Carlo method is designed to do. One example of a method to draw samples from your distribution is the Metropolis-Hastings sampler.

| cite | improve this answer | |
$\endgroup$

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.