Skip to content

ckmeansBreaks

ckmeansBreaks(x, nClasses): number[]

Defined in: src/ckmeans_breaks.js:19

Given an array of x, this will use Ckmeans clustering to compute class breaks, in the same [min, ...breaks, max] shape that equalIntervalBreaks returns. Unlike equalIntervalBreaks, which divides the range of the data evenly, each internal break here is the smallest value of the cluster it starts, so classes group together values that Ckmeans found to be most alike: a value v falls into class i when breaks[i] <= v < breaks[i + 1], and the last class also includes the maximum value.

number[]

an array of number values

number

number of desired classes

number[]

array of class break positions

ckmeansBreaks([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3); // => [-1, 2, 4, 6]