Title: | Finds Cutoff Points on Knee Curves |
---|---|
Description: | Given a set of points around a knee curve, analyzes first and second derivatives to find knee points. |
Authors: | Alan Tseng |
Maintainer: | Alan Tseng <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-10-31 06:50:16 UTC |
Source: | CRAN |
Derivative of a function with respect to x
derivative(x, y, m = 0, n = 50)
derivative(x, y, m = 0, n = 50)
x |
x coordinates of points in function's domain |
y |
y coordinates of points in function's range |
m |
the order of the derivative (0 for y, 1 for y', 2 for y”) |
n |
number of points in the domain for interpolation |
a function representing the mth derivative of y(x) with respect to x
x <- seq(0,5,0.1) y <- x^2 - 2*x + 3 # So dy/dx = 2x - 2 fp <- derivative(x, y, 1) fp(2) # 2 fp(5) # 8
x <- seq(0,5,0.1) y <- x^2 - 2*x + 3 # So dy/dx = 2x - 2 fp <- derivative(x, y, 1) fp(2) # 2 fp(5) # 8
Finds cutoff point on knee curve
findCutoff(x, y, method = "first", frac.of.steepest.slope = 0.5)
findCutoff(x, y, method = "first", frac.of.steepest.slope = 0.5)
x |
vector of x coordinates of points around curve |
y |
vector of y coordinates of points around curve |
method |
the method to define the knee point. Value can be "first" for first derivative cutoff or "curvature" for maximum curvature cutoff. |
frac.of.steepest.slope |
the slope at the cutoff point relative to the steepest (positive or negative) slope on the curve. Only used if method is set to "first". Can be set to any number > 0 or <= 1. If the knee curve is increasing and concave down, then lower numbers will lead to higher knee points, and higher numbers will lead to lower knee points. |
a list containing the (x, y) coordinates of the knee point chosen using the specified method
# Generate some knee data x <- runif(100, min=-3, max=3) y <- -exp(-x) * (1+rnorm(100)/3) plot(x, y) # Plot knee points calculated using two different methods points(findCutoff(x,y), col="red", pch=20, cex=3) points(findCutoff(x,y, method="curvature"), col="blue", pch=20, cex=3)
# Generate some knee data x <- runif(100, min=-3, max=3) y <- -exp(-x) * (1+rnorm(100)/3) plot(x, y) # Plot knee points calculated using two different methods points(findCutoff(x,y), col="red", pch=20, cex=3) points(findCutoff(x,y, method="curvature"), col="blue", pch=20, cex=3)
Finds the point on the curve that has the maximum curvature
findCutoffCurvature(x, y)
findCutoffCurvature(x, y)
x |
x coordinates of points around the curve |
y |
y coordinates of points around the curve |
(x, y) coordinates of the point with the greatest curvature
Finds the point where the derivative is a fraction of the steepest slope
findCutoffFirstDerivative(x, y, slope_ratio = 0.5)
findCutoffFirstDerivative(x, y, slope_ratio = 0.5)
x |
x coordinates of points around the curve |
y |
y coordinates of points around the curve |
slope_ratio |
the fraction of the steepest slope that defines knee point |
(x, y) coordinates of the knee point
Inverse of a function
inverse(f, domain)
inverse(f, domain)
f |
univariate function |
domain |
domain of f given as (min, max) interval |
a function g such that f(x) = y and g(y) = x
expinv <- inverse(exp, c(0,3)) expinv(exp(1))
expinv <- inverse(exp, c(0,3)) expinv(exp(1))