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]:=

"nmaGenerateRandom_1.gif"

Out[136]=

Graphics:frequency of random numbers distributed normally

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

"nmaGenerateRandom_3.gif"

Out[140]=

Graphics:frequency of random numbers distributed exponentialy

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]:=

"nmaGenerateRandom_5.gif"

Out[146]=

Graphics:frequency of random numbers distributed Gamma


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