A small note on Using Mathematica 6 to generate random variables that are distributed with specific  probability density

by Nasser Abbasi 8/30/076

The problem : We want to generate a set of random variables such that they fit a specific probability distribution. Examples are shown how to do this using Mathematica 6

The method is simple. We Wrap the specific probability distribution function with the function RandomReal or RandomInterger. Use histogram to plot the frequency distribution of the resulting random numbers. Below are 3 examples to illustrate the method.

example 1 : Generate random numbers which are distributed normally with zero mean and variance of 1. Generate 1000 random numbers and display histogram

In[134]:=

Out[136]=

example 2 : Generate random numbers which are distributed exponentially with parameter λ=1. Generate 1000 random numbers and display histogram

Out[140]=

example 3 : Generate random numbers which are distributed with Gamma Distribution with shape parameter 2 and scaleparameter 5. Generate 1000 random numbers and display histogram

In[145]:=

Out[146]=

 Created by Wolfram Mathematica 6.0 for Students - Personal Use Only  (31 August 2007)