knee

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package knee reads a threshold from data. The knee of an empirical distribution is the point of its cumulative curve farthest from the chord between the curve's ends, the place where a sparse tail turns into a dense body. A threshold taken this way is always an observed value, so a bound or an acceptance level is never a number typed into the source: the caller reports the quantile the knee sits at beside every use, and a change in the data moves the threshold.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Index

func Index(x []float64) int

Index returns the index of the point of the cumulative curve over x that lies farthest from the chord between the curve's ends. x holds the x-coordinate of each rank in ascending order; the point for rank i is (x[i], (i+1)/len(x)). Fewer than two points has no chord and Index returns zero.

Types

type Result

type Result struct {
	Threshold float64 `json:"threshold"`
	Quantile  float64 `json:"quantile"`
	Samples   int     `json:"samples"`
}

Result is a threshold read from a sample: the value at the knee, the quantile it sits at, and how many points it was read from.

func Of

func Of(sample []float64) (Result, bool)

Of sorts sample ascending and returns its knee: the observed value farthest from the chord of its cumulative curve, with the quantile it sits at. The threshold is always a value drawn from sample, never a typed constant. ok is false for fewer than two samples, which have no curve to bend.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL