Volume 9, Issue 4
Tricks of the Trade
In and Out
Download This Issue
Staff and Contributors
Stable Distributions in Mathematica
Using the Package
The StableDistribution package provides several basic functions needed for the calculation of stable distributions. They are all designed with identical input, output, and default formats. The package comes with a Help Browser that explains in more detail how each function works. It also includes a few more functions that are not described in this paper. The package allows both the 0 and 1 parameterizations for all the following functions, but in the examples and discussion only will be used.
Place the unzipped folder, StableDistribution (see Additional Material), in the Mathematica applications folder. After rebuilding the Help Browser index, documentation will be available in the Help Browser Add-ons & Links category. The following command loads the program.
The SPDF function calculates the stable density using a variation of the Zolotarev integral transformation . This transformation permits accurate calculations of both the density and distribution functions across nearly the whole domain of stable parameters. Attempts to simply numerically integrate the inverse Fourier transform of the characteristic function run into difficulties when or when is large.
Chambers, Mallows, and Stuck  published an algorithm for the generation of stable random variables. It is implemented in this package as the function, SRandom. The following example generates a stable random sequence of 10 numbers where p1 is a parameter set, .
The SRandom generator makes it easy to experience the behavior of stable distributions. The following graphics array illustrates 10,000 pseudorandom drawings from symmetric stable distributions with set at 0.9, 1.7, and 2.0. Note how extreme outliers may be for lower values of . The graphs are all at the same scale to illustrate the differences in dispersion, but at this scale some of the extreme points in the case of are not shown. A stable sample with has the same dispersion as the normal distribution. is typical of stock price returns.
The following example simulates what a series of daily stock market prices might look like if generated by a stable return model with a starting price of 50 and an expected annual return of 7% (there are about 252 trading days in a year); notice the sudden large jumps.
The StableDistribution package also has data analysis capability and can perform a fit to data. The fMLFit function provides a maximum likelihood fit to the data. The algorithm uses a fast Fourier transform of the characteristic function  to approximate the stable probability density function rapidly.
The following graph compares the fit to the empirical density of the sample.
The plot of the distribution function follows.
The SQuantile function uses FindRoot to solve for at a value of the SCDF. It can be used to print a table of cumulative probabilities. For the parameters in the preceding example:
The density and distribution functions use NIntegrate to make the calculations. A direct integral form for the first derivative of the density function is also provided, but further derivatives can also be calculated using the derivative function in Mathematica.
While the package is able to calculate most all of the range of stable distributions, it can at times be slow and may require adjustment of the input parameters to NIntegrate to obtain accurate results. With such adjustments, however, it is possible to make extremely precise calculations. The following example shows high-precision density calculations for values on the light tail of a maximally skewed stable distribution.
The SMode function can be used to locate the mode of a stable distribution; this is particularly useful when is close to 1, where the mode may be quite distant from the origin. The function uses FindRoot to determine where the first derivative of the stable density is equal to 0.
About Mathematica | Download Mathematica Player
© Wolfram Media, Inc. All rights reserved.