Skip to contents

[Experimental]

Discrete summation of functions of one variable over a finite or semi-infinite interval.

Usage

summate(fun, lower, upper, tol = 1e-10, ...)

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.

tol

a numeric value indicating the accuracy of the result (useful in infinite summations).

...

additional arguments to be passed to fun.

Details

Arguments after ... must be matched exactly. If both limits are infinite, the function fails. For semi-infinite intervals, the summation must be convergent. This is accomplished in manny probability mass functions.

Author

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

Examples

library(EstimationTools)


#----------------------------------------------------------------------------
# Example 1: Poisson expected value computation, X ~ Poisson(lambda = 15)
Poisson_integrand <- function(x, lambda) {
  x * lambda^x * exp(-lambda)/factorial(x)
}

summate(fun = Poisson_integrand, lower = 0, upper = Inf, lambda = 15)
#> [1] 15


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