R/derivative.R

derivative <-
function (fcn, x, epsilon = .Machine$double.eps, curve.scale.min = 0.1, 
    ...) 
{
    if (any(!is.finite(x))) 
        stop("NA/NaN/Inf values not allowed in 'x'")
    xc <- ifelse(abs(x) < curve.scale.min, curve.scale.min, x)
    h <- (epsilon^(1/3)) * xc
    (fcn(x + h, ...) - fcn(x - h, ...))/(2 * h)
}

Try the EnvStats package in your browser

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

EnvStats documentation built on Aug. 22, 2023, 5:09 p.m.