ghQuad | R Documentation |
Convenience function for evaluation of Gauss-Hermite quadrature
ghQuad(f, rule, ...)
f |
Function to integrate with respect to first (scalar) argument; this
does not include the weight function |
rule |
Gauss-Hermite quadrature rule to use, as produced by
|
... |
Additional arguments for f |
This function performs classical unidimensional Gauss-Hermite quadrature with the function f using the rule provided; that is, it approximates
integral( f(x) exp(-x^2), -Inf, Inf)
by evaluating
sum( w * f(x) )
Numeric (scalar) with approximation integral of f(x)*exp(-x^2) from -Inf to Inf.
Alexander W Blocker ablocker@gmail.com
Golub, G. H. and Welsch, J. H. (1969). Calculation of Gauss Quadrature Rules. Mathematics of Computation 23 (106): 221-230.
Liu, Q. and Pierce, D. A. (1994). A Note on Gauss-Hermite Quadrature. Biometrika, 81(3) 624-629.
gaussHermiteData
, ghQuad
# Get quadrature rules rule10 <- gaussHermiteData(10) rule100 <- gaussHermiteData(100) # Check that rule is implemented correctly f <- function(x) rep(1,length(x)) if (!isTRUE(all.equal(sqrt(pi), ghQuad(f, rule10), ghQuad(f, rule100)))) { print(ghQuad(f, rule10)) print(ghQuad(f, rule100)) } # These should be 1.772454 f <- function(x) x if (!isTRUE(all.equal(0.0, ghQuad(f, rule10), ghQuad(f, rule100)))) { print(ghQuad(f, rule10)) print(ghQuad(f, rule100)) } # These should be zero
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.