This family of functions use quadratures for solving integrals. The user can create a custom integration routine, see details for further information.
Arguments
- fun
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument
x
.- lower
a numeric value for the lower limit of the integral.
- upper
a numeric value for the upper limit of the integral.
- kind
character specifying the weight (polynomial) function for the quadrature.
- n
integer with the highest order of the polynomial of the selected rule.
- normalized
logical. If TRUE, rules are for orthonormal polynomials, otherwise they are for orthogonal polynomials.
- ...
additional arguments to be passed to
fun
and to the quadrature routine specified in argumentkind
.
Details
gauss_quad
uses the implementation of Gaussian quadratures from
gaussquad package.This is a wrapper that implements rules
and integration routine in the same place.
Author
Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co
Examples
library(EstimationTools)
#----------------------------------------------------------------------------
# Example 1: Mean of X ~ N(2,1) (Gauss-Hermitie quadrature).
g <- function(x, mu, sigma) sqrt(2)*sigma*x + mu
i2 <- gauss_quad(g, lower = -Inf, upper = Inf, kind = 'hermite.h',
normalized = FALSE, mu = 2, sigma = 1)
i2 <- i2/sqrt(pi)
i2
#> [1] 2
#----------------------------------------------------------------------------