Code similar to the input of the previous section is at the core of the package
The Q-functions are:
As was done in the previous section, the simplest demonstration of these functions is to show that they return only the zero-order
term when applied to the moments for the base density function. This exercise is carried out for the functions
As in the case of
The series is exactly equal to the Gaussian density function with mean and variance specified by the characteristic function. Higher-order terms are zero as expected.
In the next two examples, the functions
The results are exactly equal to the Gamma and Beta density function corresponding to the supplied moments. Again, higher-order terms are zero as expected.
The next two examples are concerned with the following sum
where is a sequence of independent random variables, each uniformly distributed on . As approaches infinity, the density function of will tend to a Gaussian density as predicted by the central limit theorem, so appears a suitable target for application of one of our density function series representations. The most common application of the methods described here are to problems of the form in equation (14). Moments of are easily found in this case provided the characteristic function of the is known.
The specific case considered is . This case is examined partly because with is still occasionally suggested as a computational algorithm to generate Gaussian variates given a uniform random number generator. The following efforts will show as a side result how well approximates a Gaussian random variate. (Evaluation of equation (14) for is a poor Gaussian random number generator, yielding mediocre accuracy for the required number of uniform variates. See  for excellent alternates.)
For this example,
The Gram-Charlier series will be evaluated for degrees 0, 5, 10, 20, and 50.
The following table compares the relative error made when approximating this value using a truncated Gram-Charlier series of the indicated degree.
Note that the series appears to converge with increasing degree as it should for this case. Normally, accuracy of the truncated series of the type considered here tends to improve as approaches the mean value, in this case zero, of the true density function.
Figure 1 contains a plot of
Figure 1 compares the exact density of with the absolute value of the truncated Gram-Charlier series. Note the sharp points on the curves, indicating where the truncated series crosses zero. If the true density were not available in this case, the first zero crossing could be used as an upper bound on the useful application domain of a given truncated series. The degree-0 curve confirms that random number generation based on would serve as a mediocre approximation to a Gaussian random variate as noted earlier.
Since is clearly distributed over a finite interval, , the Beta-series, which is based on a weight function with support on a finite interval, might better approximate the density
of . This is demonstrated in Figure 2 which contains a plot of
Figure 2. Comparison of the exact density for z with five truncated Beta-series of degree (0, 5, 10, 20, 50). Note that the curve for degree 50 is indistinguishable from the exact result, except just above the x-axis.
Copyright © 2002 Wolfram Media, Inc. All rights reserved.