1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
\name{gauss.quad}
\alias{gauss.quad}
\title{Gaussian Quadrature}
\description{Calculate nodes and weights for Gaussian quadrature.}
\usage{gauss.quad(n,kind="legendre",alpha=0,beta=0)}
\arguments{
\item{n}{number of nodes and weights}
\item{kind}{kind of Gaussian quadrature, one of \code{"legendre"}, \code{"chebyshev1"}, \code{"chebyshev2"}, \code{"hermite"}, \code{"jacobi"} or \code{"laguerre"}}
\item{alpha}{parameter for Jacobi or Laguerre quadrature, must be greater than -1}
\item{beta}{parameter for Jacobi quadrature, must be greater than -1}
}
\value{A list containing the components
\item{nodes}{vector of values at which to evaluate the function}
\item{weights}{vector of weights to give the function values}
}
\details{
The integral from \code{a} to \code{b} of \code{w(x)*f(x)} is approximated by \code{sum(w*f(x))} where \code{x} is the vector of nodes and \code{w} is the vector of weights. The approximation is exact if \code{f(x)} is a polynomial of order no more than \code{2n-1}.
The possible choices for \code{w(x)}, \code{a} and \code{b} are as follows:
Legendre quadrature: \code{w(x)=1} on \code{(-1,1)}.
Chebyshev quadrature of the 1st kind: \code{w(x)=1/sqrt(1-x^2)} on \code{(-1,1)}.
Chebyshev quadrature of the 2nd kind: \code{w(x)=sqrt(1-x^2)} on \code{(-1,1)}.
Hermite quadrature: \code{w(x)=exp(-x^2)} on \code{(-Inf,Inf)}.
Jacobi quadrature: \code{w(x)=(1-x)^alpha*(1+x)^beta} on \code{(-1,1)}. Note that Chebyshev quadrature is a special case of this.
Laguerre quadrature: \code{w(x)=x^alpha*exp(-x)} on \code{(0,Inf)}.
The method is explained in Golub and Welsch (1969).
}
\references{
Golub, G. H., and Welsch, J. H. (1969). Calculation of Gaussian
quadrature rules. \emph{Mathematics of Computation} \bold{23}, 221-230.
Golub, G. H. (1973). Some modified matrix eigenvalue problems.
\emph{Siam Review} \bold{15}, 318-334.
Smyth, G. K. (1998). Numerical integration. In: \emph{Encyclopedia of Biostatistics}, P. Armitage and T. Colton (eds.), Wiley, London, pages 3088-3095.
\url{http://www.statsci.org/smyth/pubs/EoB/ban042-.pdf}
Smyth, G. K. (1998). Polynomial approximation. In: \emph{Encyclopedia of Biostatistics}, P. Armitage and T. Colton (eds.), Wiley, London, pages 3425-3429.
\url{http://www.statsci.org/smyth/pubs/EoB/bap064-.pdf}
Stroud, AH, and Secrest, D (1966). \emph{Gaussian Quadrature Formulas}. Prentice-Hall, Englewood Cliffs, N.J.
}
\author{Gordon Smyth, using Netlib Fortran code \url{http://www.netlib.org/go/gaussq.f}, and including a suggestion from Stephane Laurent}
\seealso{
\code{\link[statmod:gauss.quad.prob]{gauss.quad.prob}}, \code{\link{integrate}}
}
\examples{
# mean of gamma distribution with alpha=6
out <- gauss.quad(10,"laguerre",alpha=5)
sum(out$weights * out$nodes) / gamma(6)
}
\keyword{math}
|