HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletdigest-0.3Haskell2010

Data.TDigest.Tree.Internal

Internals of TDigest.

Tree implementation is based on Adams’ Trees Revisited by Milan Straka http://fox.ucw.cz/papers/bbtree/bbtree.pdf

  • 1 type
  • 29 values
  • Packagetdigest-0.3
  • Exports30
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternal.hs
datadata TDigest (compression :: Nat)
#

TDigest is a tree of centroids.

compression is a 1/δ. The greater the value of compression the less likely value merging will happen.

Constructors

Instances7Reducer, Show, Semigroup, Monoid, NFData, Binary, …

But*, the benefit vs. code explosion is not yet worth.

29 declarations
valuetotalWeight :: TDigest comp -> Weight
#

Total count of samples.

Example1 expression
totalWeight (tdigest [1..100] :: TDigest 5)100.0
valueminimumValue :: TDigest comp -> Mean
#

Center of left-most centroid. Note: may be different than min element inserted.

Example1 expression
minimumValue (tdigest [1..100] :: TDigest 3)1.0
valuemaximumValue :: TDigest comp -> Mean
#

Center of right-most centroid. Note: may be different than max element inserted.

Example1 expression
maximumValue (tdigest [1..100] :: TDigest 3)99.0
valuecompress :: KnownNat comp => TDigest comp -> TDigest comp
#

Compress TDigest.

Reinsert the centroids in "better" order (in original paper: in random) so they have opportunity to merge.

Compression will happen only if size is both: bigger than relMaxSize * comp and bigger than absMaxSize.

valuerelMaxSize :: Int
#

Relative size parameter. Hard-coded value: 25.

valueabsMaxSize :: Int
#

Absolute size parameter. Hard-coded value: 1000.

valueinsert'
  1. :: KnownNat comp
  2. => Double

    element

  3. -> TDigest comp
  4. -> TDigest comp
#

Insert single value, don't compress TDigest even if needed.

For sensibly bounded input, it makes sense to let TDigest grow (it might grow linearly in size), and after that compress it once.

Example1 expression
:set -XDataKinds