dapx_gca(x, raw.moments, support=c(-Inf,Inf), log=FALSE)papx_gca(q, raw.moments, support=c(-Inf,Inf), lower.tail=TRUE, log.p=FALSE)
x, or the approximate CDF at
q.Suppose $f(x)$ is the probability density of some random variable, and let $F(x)$ be the cumulative distribution function. Let $He_j(x)$ be the $j$th probabilist's Hermite polynomial. These polynomials form an orthogonal basis, with respect to the function $w(x)$ of the Hilbert space of functions which are square $w$-weighted integrable. The weighting functimn is $w(x) = e^{-x^2/2} = \sqrt{2\pi}\phi(x)$. The orthogonality relationship is $$\int_{-\infty}^{\infty} He_i(x) He_j(x) w(x) \mathrm{d}x = \sqrt{2\pi} j! \delta_{ij}.$$
Expanding the density $f(x)$ in terms of these polynomials in the usual way (abusing orthogonality) one has $$f(x) = \sum_{0\le j} \frac{He_j(x)}{j!} \phi(x) \int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$ The cumulative distribution function is 'simply' the integral of this expansion. Abusing certain facts regarding the PDF and CDF of the normal distribution and the probabilist's Hermite polynomials, the CDF has the representation $$F(x) = \Phi(x) - \sum_{1\le j} \frac{He_{j-1}(x)}{j!} \phi(x) \int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$
These series contain coefficients defined by the probability distribution under consideration. They take the form $$c_j = \frac{1}{j!}\int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$ Using linearity of the integral, these coefficients are easily computed in terms of the coefficients of the Hermite polynomials and the raw, uncentered moments of the probability distribution under consideration. Note that it may be the case that the computation of these coefficients suffers from bad numerical cancellation for some distributions, and that an alternative formulation may be more numerically robust.
S. Blinnikov and R. Moessner. "Expansions for nearly Gaussian
distributions." Astronomy and Astrophysics Supplement 130 (1998): 193-205.
qapx_cf# normal distribution:
xvals <- seq(-2,2,length.out=501)
d1 <- dapx_gca(xvals, c(0,1,0,3,0))
d2 <- dnorm(xvals)
d1 - d2
qvals <- seq(-2,2,length.out=501)
p1 <- papx_gca(qvals, c(0,1,0,3,0))
p2 <- pnorm(qvals)
p1 - p2Run the code above in your browser using DataLab