Random Values from Distributions

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

To observe values of a random variable that follows some arbitrary distribution, it is only necessary to be able to generate random numbers distributed uniformly in the unit interval and to compute quantiles of the desired distribution. (See the Demonstration "Using Rule 30 to Generate Pseudorandom Real Numbers" for a way to do the former.) The random number from the unit interval is simply used as the desired quantile of the more general distribution. That is, if is the density function for the distribution from which a random value is to be drawn and is a random number from the unit interval, the number is taken such that the area to the left of under is equal to . Thus, the pink area is equal to and the vertical line in the lower plot is at .

Contributed by: Chris Boucher (March 2011)
Open content licensed under CC BY-NC-SA


Snapshots


Details

This Demonstration shows a general theoretical approach to generating random values from non-uniform distributions. Implementing it, however, requires computing the inverse of the cumulative distribution function (CDF) at the quantile in question. This can be computationally intensive if the CDF is complicated. In practice, random number generators often use other methods that are computationally faster.



Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.
Send