R/trapint.r

Defines functions .trapint

#' @keywords internal
############### R-function: trapint ###############

# For performing trapezoidal integration.

# Last changed: 13 NOV 2003

.trapint <- function(xgrid,fgrid)
{
   ng <- length(xgrid)

   xvec <- xgrid[2:ng] - xgrid[1:(ng-1)]
   fvec <- fgrid[1:(ng-1)] + fgrid[2:ng]

   integ <- sum(xvec*fvec)/2

   return(integ)
}

############### End trapint ###############

Try the reldist package in your browser

Any scripts or data that you put into this service are public.

reldist documentation built on March 7, 2023, 8:34 p.m.