gauss_quad {EstimationTools}R Documentation

Numerical integration through Gaussian Quadrature

Description

[Experimental]

This family of functions use quadratures for solving integrals. The user can create a custom integration routine, see details for further information.

Usage

gauss_quad(
  fun,
  lower,
  upper,
  kind = "legendre",
  n = 10,
  normalized = FALSE,
  ...
)

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 argument kind.

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.

Value

The value of the integral of the function specified in fun argument.

Author(s)

Jaime Mosquera GutiƩrrez, jmosquerag@unal.edu.co

See Also

laguerre.quadrature, legendre.quadrature, chebyshev.c.quadrature, gegenbauer.quadrature, hermite.h.quadrature, etc.

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


#----------------------------------------------------------------------------


[Package EstimationTools version 4.0.0 Index]