Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
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]:= Needs@"Histograms`"D t = Table@RandomReal@NormalDistribution@0, 1DD, 8i, 1000<D; Histogram@t, PlotLabel ® "frequency of random numbers distributed normally", AxesLabel ® 8"x", "frequency"<D frequency of random numbers distributed normally frequency 100 80 Out[136]= 60 40 20 -2 x 0 2 Printed by Mathematica for Students 2 nmaGenerateRandom.nb example 2 : Generate random numbers which are distributed exponentially with parameter Λ=1. Generate 1000 random numbers and display histogram t = Table@RandomReal@ExponentialDistribution@1DD, 8i, 1000<D; Histogram@t, PlotLabel ® "frequency of random numbers distributed exponentially", AxesLabel ® 8"x", "frequency"<D frequency of random numbers distributed exponentialy frequency 200 150 Out[140]= 100 50 x 2 4 6 8 Printed by Mathematica for Students nmaGenerateRandom.nb 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]:= t = Table@RandomReal@GammaDistribution@2, 5DD, 8i, 1000<D; Histogram@t, PlotLabel ® "frequency of random numbers distributed Gamma", AxesLabel ® 8"x", "frequency"<D frequency of random numbers distributed Gamma frequency 140 120 100 Out[146]= 80 60 40 20 x 10 20 30 40 50 Printed by Mathematica for Students 3