Moment-Based Density Approximants
Appendix
This appendix contains the Mathematica code that was used in connection with each of the seven examples. All the calculations are carried out with rational numbers so as to prevent any loss of precision. It would be advisable to quit the kernel between examples.
Code for Example 1
The end points of the support of the random variable are
and
. The degree of the polynomial approximation is
. In this example, the random variable of interest is
, which will be denoted by
to conform to the general notation utilised in Section 4. Its
th moment is given by
whereas the
th moment of
defined on the interval
is denoted by
. The exact density function is denoted by
and the approximate density functions obtained from equations (13) and (15) are given by
and
, respectively. The exact and approximate cumulative distribution functions obtained by integration are denoted by
and
, respectively.
Code for Example 2
The end points of the support of the random variable are
and
. The degree of the polynomial approximation is
. For a given sequence of moments,
,
, the approximate density,
, is obtained from equation (14) in this case.
Code for Example 3
The
th moment of the standard lognormal distribution whose support is the positive half-line is
. The exact and approximate density functions are respectively given by
and
, the latter being obtained from equation (28).
denotes the distribution function corresponding to
.
Code for Example 4
The
th moment of the mixture of three shifted gamma random variables, which is denoted by
, is obtained by differentiation of the moment-generating function,
. The degree of the polynomial approximation is
. The exact and approximate density functions are respectively given by
and
, the latter being determined from equation (29).
Code for Example 5
We use the notation introduced in Section 4. First, we approximate the density function of the random variable
as defined in Section 2 by making use of equation (42) with
, a modified Jacobi polynomial. To conform to the general notation used in Section 4, we will again replace
with
.
Identical density approximants denoted by
and
in the following code are obtained from Result 4.1 and equation (43), respectively.
Code for Example 6
We use Result 4.1 to approximate the density of Wilks' likelihood ratio criterion, which will be denoted by
to conform to the general notation utilised in Section 4. In this case, both
and
are defined on the interval
. The transformation is included in the code so that it could be applied if needed. The symbol N being protected, it is replaced by
in the following code.
Code for Example 7
We use the notation introduced in Section 4. First, we approximate the density function of the Gaussian mixture with
by making use of an alternate representation of equation (42) with
, a modified Hermite polynomial. The function
provides an approximant which is directly expressed in terms of the moments of
.
The same density approximant is obtained from equation (32).