Package 'KneeArrower'

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

Help Index


Derivative of a function with respect to x

Description

Derivative of a function with respect to x

Usage

derivative(x, y, m = 0, n = 50)

Arguments

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

Value

a function representing the mth derivative of y(x) with respect to x

Examples

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

Description

Finds cutoff point on knee curve

Usage

findCutoff(x, y, method = "first", frac.of.steepest.slope = 0.5)

Arguments

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.

Value

a list containing the (x, y) coordinates of the knee point chosen using the specified method

Examples

# 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

Description

Finds the point on the curve that has the maximum curvature

Usage

findCutoffCurvature(x, y)

Arguments

x

x coordinates of points around the curve

y

y coordinates of points around the curve

Value

(x, y) coordinates of the point with the greatest curvature


Finds the point where the derivative is a fraction of the steepest slope

Description

Finds the point where the derivative is a fraction of the steepest slope

Usage

findCutoffFirstDerivative(x, y, slope_ratio = 0.5)

Arguments

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

Value

(x, y) coordinates of the knee point


Inverse of a function

Description

Inverse of a function

Usage

inverse(f, domain)

Arguments

f

univariate function

domain

domain of f given as (min, max) interval

Value

a function g such that f(x) = y and g(y) = x

Examples

expinv <- inverse(exp, c(0,3))
expinv(exp(1))