## Generating Random Numbers from Custom Probability Distributions

STELLA^{®} and *iThink*^{®} provide many useful probability distribution functions (listed here). However, sometimes you need to draw random numbers from a different probability distribution, perhaps one you have developed yourself. In these cases, it is possible to invert the cumulative probability distribution and use a uniformly distributed random number between zero and one (using the RANDOM built-in) to draw a number from the intended distribution. With a lot of math, this can be done analytically (briefly described here). With no math at all, it can be closely approximated using the graphical function.

**Find the Cumulative Distribution Function**

Every probability distribution has a *probability density function* (PDF) that relates a value with its probability of occurring. The most famous continuous PDF is the bell curve for the normal distribution:

From the PDF, we can see that the probability of randomly drawing 100 is just under 0.09 while the probability of randomly drawing 88 or 112 is close to zero. Note that applying the techniques described in this article to a continuous probability distribution will only approximate that distribution. The accuracy of the approximation will be determined by the number of data points included in the graphical function.

For discrete probability functions, the PDF resembles a histogram:

From this PDF, we can see that the probability of randomly drawing 1 is 0.4, while the probability of drawing 3 is 0.15. As discrete probability distributions can be represented exactly within graphical functions, the remainder of this article will focus on them.