tdigest-0.2.1: On-line accumulation of rank-based statistics

Safe HaskellNone
LanguageHaskell2010

Data.TDigest.Vector.Internal

Synopsis

Documentation

data TDigest (compression :: Nat) Source #

TDigest is a vector of centroids plus not yet merged elements.

The size of structure is dictated by compression, *𝛿*. And is *O(𝛿)*.

Constructors

TDigest 

Fields

Instances
KnownNat comp => Reducer Double (TDigest comp) Source #

Both cons and snoc are insert

Instance details

Defined in Data.TDigest.Vector.Internal

Methods

unit :: Double -> TDigest comp #

snoc :: TDigest comp -> Double -> TDigest comp #

cons :: Double -> TDigest comp -> TDigest comp #

Show (TDigest compression) Source # 
Instance details

Defined in Data.TDigest.Vector.Internal

Methods

showsPrec :: Int -> TDigest compression -> ShowS #

show :: TDigest compression -> String #

showList :: [TDigest compression] -> ShowS #

KnownNat comp => Semigroup (TDigest comp) Source # 
Instance details

Defined in Data.TDigest.Vector.Internal

Methods

(<>) :: TDigest comp -> TDigest comp -> TDigest comp #

sconcat :: NonEmpty (TDigest comp) -> TDigest comp #

stimes :: Integral b => b -> TDigest comp -> TDigest comp #

KnownNat comp => Monoid (TDigest comp) Source # 
Instance details

Defined in Data.TDigest.Vector.Internal

Methods

mempty :: TDigest comp #

mappend :: TDigest comp -> TDigest comp -> TDigest comp #

mconcat :: [TDigest comp] -> TDigest comp #

NFData (TDigest comp) Source # 
Instance details

Defined in Data.TDigest.Vector.Internal

Methods

rnf :: TDigest comp -> () #

KnownNat comp => HasHistogram (TDigest comp) Maybe Source # 
Instance details

Defined in Data.TDigest.Vector.Internal

size :: TDigest comp -> Int Source #

Size of structure

minimumValue :: KnownNat comp => TDigest comp -> Mean Source #

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

>>> minimumValue (tdigest [1..100] :: TDigest 3)
1.0

maximumValue :: KnownNat comp => TDigest comp -> Mean Source #

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

>>> maximumValue (tdigest [1..100] :: TDigest 3)
100.0

ksize Source #

Arguments

:: Double

compression parameter, 𝛿

-> Double

quantile, q

-> Double

notional index, k

Mapping from quantile *q* to notional index *k* with compression parameter *𝛿*.

>>> ksize 42 0
0.0
>>> ksize 42 1
42.0
  • q@ is clamped.:
>>> ksize 42 2
42.0

ksizeInv Source #

Arguments

:: Double

compression parameter, 𝛿

-> Double

notional index, k

-> Double

quantile, q

Inverse of ksize.

>>> ksizeInv 42 0
0.0
>>> ksizeInv 42 42
1.0
>>> ksizeInv 42 (ksize 42 0.3)
0.3

merge :: Int -> Double -> [(Mean, Weight)] -> [(Mean, Weight)] Source #

combineTDigest :: forall comp. KnownNat comp => TDigest comp -> TDigest comp -> TDigest comp Source #

finalize :: forall comp. KnownNat comp => TDigest comp -> TDigest comp Source #

Flush insertion buffer

forceCompress :: forall comp. KnownNat comp => TDigest comp -> TDigest comp Source #

compress :: forall comp. KnownNat comp => TDigest comp -> TDigest comp Source #

validate :: TDigest comp -> Either String (TDigest comp) Source #

Check various invariants in the TDigest structure.

insert Source #

Arguments

:: KnownNat comp 
=> Double

element

-> TDigest comp 
-> TDigest comp 

Insert single value into TDigest.

insert' Source #

Arguments

:: KnownNat comp 
=> Double

element

-> TDigest comp 
-> TDigest comp 

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

This may violate the insertion buffer size invariant.

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

singleton :: Double -> TDigest comp Source #

Make a TDigest of a single data point.

tdigest :: (Foldable f, KnownNat comp) => f Double -> TDigest comp Source #

Strict foldl' over Foldable structure.

>>> :set -XDataKinds