Kneedle 1.0.1

dotnet add package Kneedle --version 1.0.1                
NuGet\Install-Package Kneedle -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kneedle" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kneedle --version 1.0.1                
#r "nuget: Kneedle, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kneedle as a Cake Addin
#addin nuget:?package=Kneedle&version=1.0.1

// Install Kneedle as a Cake Tool
#tool nuget:?package=Kneedle&version=1.0.1                

Kneedle

Implementation of knee/elbow finding algorithm 'Kneedle' in C#.

Calculates knee points using the Kneedle algorithm. Returns the x value corresponding to the knee point when successful, null otherwise.

Contains only batch mode implementation right now. Contributoins welcome for online/streaming implementation, as well as any other improvements!

Reference

"Finding a ‘kneedle’ in a haystack: Detecting knee points in system behavior. "
Satopaa, V and Albrecht, J and Irwin, D and Raghavan, B
31-st International Conference on Distributed Computing Systems
2011

https://raghavan.usc.edu/papers/kneedle-simplex11.pdf

Usage

var y = new double[] { 1, 1, 0.894, 0.864, 0.859, 0.856, 0.852, 0.851, 0.849, 0.848, 0.847, 0.845 };
var x = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

var k1 = KneedleAlgorithm.CalculateKneePoints(x, y, CurveDirection.Decreasing, Curvature.Counterclockwise, forceLinearInterpolation: false); 
// Returns 4

var k2 = KneedleAlgorithm.CalculateKneePoints(x, y, CurveDirection.Decreasing, Curvature.Clockwise, forceLinearInterpolation: false);
// Returns 2

Inputs

x: X axis values of the points. Points must be sorted in ascending order w.r.t. X axis.

y: Y axis values of the points.

direction: If the curve is increasing or decreasing. Make sure to set this value according to the input curve.

concavity: Whether the curve has positive or negative curvature. In other words, concave or convex. Whether the tangent rotates clockwise or counterclockwise. Make sure to set this value according to the input curve.

sensitivity: Adjusts the knee detection threshold. Defaults to 1 as per the paper.

forceLinearInterpolation: Interpolation is done using robust cubic splines. For some inputs, spline can overshoot. This param forces linear interpolation instead of cubic spline.

Output

Returns the x value corresponding to the knee point.

Can return null when the algorithm fails to identify a knee/elbow for various reasons:

  • the number of data points is too small
  • there are no local maxima on the diffs, which means either the curve is a line, or the parameters provided are incompatible with the curve

Dependencies

MathNet.Numerics from NuGet.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 4,573 3/19/2019
1.0.0 682 1/8/2019