Since the actual package is too lengthy to present here, some code segments similar to those in the package will be presented.
The discussion here should help all those interested in modifying the contents of the package for their own needs. The specific
problem considered here is the generation of the Gram-Charlier series for a probability density function given its characteristic
As noted previously, the resident function
HermiteH is defined with respect to a different weight than is natural for the problem at hand. An alternate function,
HermiteE, with the correct weight in Table 1 is defined for use here.
Expand is strictly for economy. It keeps the resultant polynomial in simple, standard form during the recursion, allowing polynomial
coefficients to be quickly extracted later.
The first argument to
HermiteE is the polynomial degree. A quick check of
HermiteE gives the expected result.
Two functions will be defined to carry out the linear combination of moments in equation (5). The first function,
BuildMoments, will build up a list of moments from the characteristic function. The second function,
aGramCharlier, will simply perform the vector multiplication indicated on the right-hand side of equation (5).
Before writing out the code segment for
BuildMoments, recall from elementary probability theory that the characteristic function of a density function, , is
The moments of may be found from using
BuildMoments appends the nth moment, evaluated using the input characteristic function as in equation (11), to a list of the first moments which have been evaluated on previous calls to
Evaluation of equation (5) is finalized using the function
aGramCharlier, whose magnitude is equivalent to (see equation (4)) for the Gram-Charlier series. (Note that this function gives the series coefficient commonly defined in
textbooks for the Gram-Charlier series.)
As a test problem, the Gram-Charlier series of the following Gaussian density function will be found.
Let the random variable have the above density: then as given in equation (3) has the following characteristic function.
In final preparation for evaluation of the Gram-Charlier series, the list of moments is initialized to the first three moments
aGramCharlier three times.
aGramCharlier should return the above result for , given any random variable , assuming the moments of are bounded through order 2. With
aGramCharlier defined as above, evaluation of the first 20 terms of equation (1) is readily carried out for the Gram-Charlier series via
Not a very exciting result at first glance. The base PDF was returned with the same mean and variance as as expected. (Note
sx above.) As a test case, however, it is important that all 19 higher-order terms were returned as zero.
Copyright © 2002 Wolfram Media, Inc. All rights reserved.[Article Index][Prev Page][Next Page]