newmana / chroma-elm / Chroma.Limits.CkMeans

A log linear implementation of CkMeans. It uses a divide-and-conquer algorithm to compute a row in the dynamic programming matrix in O(n log n) time. The Simple Statistic's implementation was used to validate this implementation.

There is a better one (not implemented) using the SMAWK optimisation.

The limit function produces class breaks like the other implementations and binned puts all data values into their bins.

Definition

binned : Basics.Int -> Chroma.Limits.Analyze.Scale -> List.Nonempty.Nonempty (Array Basics.Float)

Return the values in Scale into the given number of bins.

Analyze.analyze (Nonempty.Nonempty 3 [1,3,4,3])
|> binned 3
-->  Nonempty.Nonempty [1] [[3,3,3], [4]]

limit : Basics.Int -> Chroma.Limits.Analyze.Scale -> List.Nonempty.Nonempty Basics.Float

Create up to bins number of results using the given scale.

Analyze.analyze (Nonempty.Nonempty 3 [1,3,4,3])
|> limit 3
-->  Nonempty.Nonempty 1 [3,4]

Helpers

converge : Basics.Int -> Basics.Int -> Basics.Int -> Basics.Float -> CkRest -> ( Basics.Float, Basics.Int )

TBD

defaultResult : Basics.Int -> Basics.Int -> CkResult

TBD

fillRestOfMatrix : Basics.Int -> Chroma.Limits.Analyze.Scale -> CkRest -> CkResult

TBD

firstLine : Basics.Int -> Chroma.Limits.Analyze.Scale -> CkRest

TBD

getMatrixIndexes : Basics.Int -> List Basics.Int

TBD

getValues : Basics.Int -> Basics.Int -> List ( Basics.Int, Basics.Int )

TBD


type alias BacktrackMatrixLine =
Array Basics.Int

TBD


type alias CkRest =
{ sums : Array Basics.Float
, sumsOfSquares : Array Basics.Float
, matrix : Array MatrixLine
, previousMatrix : MatrixLine
, backmatrix : Array BacktrackMatrixLine
, previousBackmatrix : BacktrackMatrixLine 
}

TBD


type alias CkResult =
{ sums : Array Basics.Float
, sumsOfSquares : Array Basics.Float
, matrix : Array MatrixLine
, backmatrix : Array BacktrackMatrixLine 
}

TBD


type alias MatrixLine =
Array Basics.Float

TBD