Home

Staff
     
Consulting
               
Mathematica Tools

Customer Quotes
        
Contact

Older Mathematica Items

 

 

 

 

 

Scientific Arts

Maxwellian Probability Distribution Function

Page 1 | Page 2 | Page 3 | Page 4


Interpolation Function Method

We need to invert [Graphics:../Images/maxwellpdf_gr_34.gif]. Here is a plot.

[Graphics:../Images/maxwellpdf_gr_35.gif]

[Graphics:../Images/maxwellpdf_gr_36.gif]

We see that the cumulative is quite close to 1 by the time [Graphics:../Images/maxwellpdf_gr_37.gif]. The error (the "left over probability") in stopping at this value of [Graphics:../Images/maxwellpdf_gr_38.gif] is

[Graphics:../Images/maxwellpdf_gr_39.gif]
[Graphics:../Images/maxwellpdf_gr_40.gif]

If we sample [Graphics:../Images/maxwellpdf_gr_41.gif] at a sequence of points, we can form ordered pairs of those points with the [Graphics:../Images/maxwellpdf_gr_42.gif] and [Graphics:../Images/maxwellpdf_gr_43.gif] order reversed. From a list of such points we can then form an InterpolatingFunction object through the use of Mathematica's Interpolation function. One way to do this is to just use the Table function as in

[Graphics:../Images/maxwellpdf_gr_44.gif]

This method samples MaxwellCDF at regularly separated points. Another way to do the sampling is to make use of the adaptive algorithm that is used internally by the Plot function. The Graphics object returned by the Plot function above (and abbreviated as  [Graphics:../Images/maxwellpdf_gr_45.gif]  in the output) contains within it the sampled data points that Plot's internal algorithm obtained. We can see the structure of CDFPlot by looking at its InputForm (and we wrap it in the function Short so that not all of its contents are displayed).

[Graphics:../Images/maxwellpdf_gr_46.gif]
[Graphics:../Images/maxwellpdf_gr_47.gif]

The data that we are interested in is contained in the argument of the Line graphics primitive. This can be accessed by just taking the correct Part of CDFPlot. Once we have this we need to reverse the [Graphics:../Images/maxwellpdf_gr_48.gif] and [Graphics:../Images/maxwellpdf_gr_49.gif] order:

[Graphics:../Images/maxwellpdf_gr_50.gif]

 

In the above function we extracted the data from the Graphics function by directly accessing the needed Part of the expression. Another way to do this is to use pattern matching and transformation rules as follows.

[Graphics:../Images/maxwellpdf_gr_51.gif]


then, [Graphics:../Images/maxwellpdf_gr_52.gif].

 

We can now define an inverse function (using the data that was generated by the Plot command).

[Graphics:../Images/maxwellpdf_gr_53.gif]
[Graphics:../Images/maxwellpdf_gr_54.gif]

This interpolation function is not well defined outside of the range of the sample points, given by the first argument of the InterpolatingFunction (the second argument is suppressed in the output).

[Graphics:../Images/maxwellpdf_gr_55.gif]
  {{6.855672916839493*^-21, 0.999999999920108}}

Here is an example of a Maxwellian random number.

[Graphics:../Images/maxwellpdf_gr_56.gif]
[Graphics:../Images/maxwellpdf_gr_57.gif]

So we can extend the Random function. We associate this extension with MaxwellPDF rather than Random.

[Graphics:../Images/maxwellpdf_gr_58.gif]

Now let's generate a list of 5000 Maxwellian random numbers.

[Graphics:../Images/maxwellpdf_gr_59.gif]

To look at this data we can histogram it. First we load the standard add-on package, Statistics`DataManipulation`.

[Graphics:../Images/maxwellpdf_gr_60.gif]

Now we can use the function BinCounts.

[Graphics:../Images/maxwellpdf_gr_61.gif]
[Graphics:../Images/maxwellpdf_gr_62.gif]

Here is the binned data.

[Graphics:../Images/maxwellpdf_gr_63.gif]

Let's visualize the result in the form of a histogram along with a plot of MaxwellPDF for comparison.

[Graphics:../Images/maxwellpdf_gr_64.gif]
[Graphics:../Images/maxwellpdf_gr_65.gif]

[Graphics:../Images/maxwellpdf_gr_66.gif]

 

<<Previous Next >>


For further information on our services send email to info@scientificarts.com .
Contents of this web site Copyright © 1999-2011, Scientific Arts, LLC.

s