gauss.quad.prob: Gaussian Quadrature with Probability Distributions
DescriptionCalculate nodes and weights for Gaussian quadrature in terms of probability distributions.
number of nodes and weights
distribution that Gaussian quadrature is based on, one of
lower limit of uniform distribution
upper limit of uniform distribution
mean of normal distribution
standard deviation of normal distribution
positive shape parameter for beta or gamma distribution
positive scale parameter for gamma distribution
- A list containing the components
- nodesvector of values at which to evaluate the function
- weightsvector of weights to give the function values
DetailsThis is a rewriting and simplification of
gauss.quad in terms of probability distributions.
The expected value of
f(X) is approximated by
x is the vector of nodes and
w is the vector of weights. The approximation is exact if
f(x) is a polynomial of order no more than
The possible choices for the distribution of
X are as follows:
Normal with mean
mu and standard deviation
Beta with density
Gamma with density
ReferencesGolub, G. H., and Welsch, J. H. (1969). Calculation of Gaussian
quadrature rules. Mathematics of Computation 23, 221-230.
Golub, G. H. (1973). Some modified matrix eigenvalue problems.
Siam Review 15, 318-334.
Stroud and Secrest (1966). Gaussian Quadrature Formulas. Prentice-
Hall, Englewood Cliffs, N.J.
out <- gauss.quad.prob(10,"normal")
sum(out$weights * out$nodes^4)
# the 4th moment of the standard normal is 3
out <- gauss.quad.prob(32,"gamma",alpha=5)
sum(out$weights * log(out$nodes))
# the expected value of log(X) where X is gamma is digamma(alpha)