Interpolate the location of a peak based on three points
interpolate_peak_location.Rd
Uses a parabolic approximation to determine the location of a peak from 3 points.
Usage
interpolate_peak_location(y, x = c(-1, 0, 1))
Arguments
- y
3 points on the curve, where the peak/trough should be at
y[2]
, so thaty[1]
andy[3]
are lower/higher, respectively, thany[2]
- x
x coordinates. Defaults to
x = c(-1, 0, 1)
, so that the output is an offset of the peak location from what was originally detected. It could also be the truex
coordinates, which is important if they're unevenly spaced.
Examples
y <- c(1, 2, 0.5)
interpolate_peak_location(y)
#> [1] -0.1