simpson_coefficients: Find coefficients used in Simpson's approximation for...

Description Usage Arguments Value Author(s) References Examples

View source: R/simpson_coefficients.R

Description

Takes an increasing, equally spaced numeric vector 'x' and returns Simpson's Rule cofficients used in numerical integration.

Usage

1
2
3
4
5
6
simpson_coefficients(
  x,
  return_list = FALSE,
  diff_TOL = 0.001,
  suppress_warning = TRUE
)

Arguments

x

numeric vector of abcissa values in ascending order.

return_list

logical whether to return computed coefficients in a vector or the separate components in a list.

diff_TOL

numeric measure of how uneven the x-values can be (they should be evenly spaced).

suppress_warning

logical for whether to return warning.

Value

vector of numeric cofficients if return_list is TRUE; list of integers coefficients and interval size "h" separately if return_list is FALSE

Author(s)

Bill Forrest <forrest@gene.com>

Bill Forrest forrest@gene.com

References

www.r-project.org

Examples

1
2
3
4
5
 x <- seq(0, 1, by = .1); y <- 6 * x * ( 1 - x )
 w <- simpson_coefficients( x )
 print( sum( w * y ) )

 simpson_coefficients( x, return_list = TRUE )

wfforrest/maeve documentation built on Jan. 1, 2021, 12:47 p.m.