approximate_first_derivative: Approximate the first derivative of a spline passing through...

Description Usage Arguments Value Author(s) References Examples

View source: R/approximate_first_derivative.R

Description

Approximate the first derivative of a spline passing through a set of (x,y) pairs.

Usage

1
2
3
4
5
6
7
approximate_first_derivative(
  x,
  y,
  relative_tolerance = 0.01,
  dx_frac = 0.01,
  extended_output = FALSE
)

Arguments

x

numeric abcissa values for the spline. Should be

y

numeric ordinae values for the spline.

relative_tolerance

numeric tolerance parameter for how close to uniformly spaced the x-values must be.

dx_frac

numeric relative value for how far out to step from given x-values in approximating first derivative.

extended_output

logical. Whether to return a data frame with all the components leading to the first derivative.

Value

A numeric vector the same length as x & y with the first derivative of a spline through the points, or a data.frame if extended_output == TRUE.

Author(s)

Bill Forrest <forrest@gene.com>

Bill Forrest forrest@gene.com

References

www.r-project.org

Examples

1
2
3
4
 x <- seq(0, 2*pi, length = 101); 
 y <- sin(x) 
 dy.dx <- maeve:::approximate_first_derivative(x,y); 
 results <- cbind( x, y, cos(x), dy.dx ) # 3rd & 4th columns should match closely

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