Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.TDigest.Tree.Internal
Description
Internals of TDigest
.
Tree implementation is based on Adams’ Trees Revisited by Milan Straka http://fox.ucw.cz/papers/bbtree/bbtree.pdf
Synopsis
- data TDigest (compression :: Nat)
- getCentroids :: forall (comp :: Nat). TDigest comp -> [Centroid]
- totalWeight :: forall (comp :: Nat). TDigest comp -> Weight
- size :: forall (comp :: Nat). TDigest comp -> Int
- minimumValue :: forall (comp :: Nat). TDigest comp -> Mean
- maximumValue :: forall (comp :: Nat). TDigest comp -> Mean
- emptyTDigest :: forall (comp :: Nat). TDigest comp
- combineDigest :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp -> TDigest comp
- insertCentroid :: forall (comp :: Nat). KnownNat comp => Centroid -> TDigest comp -> TDigest comp
- node :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp
- balanceR :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp
- balanceL :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp
- node' :: forall (comp :: Nat). Int -> Mean -> Weight -> Weight -> TDigest comp -> TDigest comp -> TDigest comp
- singNode :: forall (comp :: Nat). Mean -> Weight -> TDigest comp
- combinedCentroid :: Mean -> Weight -> Mean -> Weight -> Centroid
- threshold :: Double -> Double -> Double -> Double
- compress :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp
- forceCompress :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp
- toMVector :: forall (comp :: Nat) s. KnownNat comp => TDigest comp -> ST s (MVector s (Centroid, Double))
- relMaxSize :: Int
- absMaxSize :: Int
- balOmega :: Int
- balAlpha :: Int
- debugPrint :: forall (comp :: Nat). TDigest comp -> IO ()
- valid :: forall (comp :: Nat). TDigest comp -> Bool
- validate :: forall (comp :: Nat). TDigest comp -> Either String (TDigest comp)
- insert :: forall (comp :: Nat). KnownNat comp => Double -> TDigest comp -> TDigest comp
- insert' :: forall (comp :: Nat). KnownNat comp => Double -> TDigest comp -> TDigest comp
- singleton :: forall (comp :: Nat). KnownNat comp => Double -> TDigest comp
- tdigest :: forall f (comp :: Nat). (Foldable f, KnownNat comp) => f Double -> TDigest comp
Documentation
data TDigest (compression :: Nat) Source #
TDigest
is a tree of centroids.
compression
is a 1/δ
. The greater the value of compression
the less
likely value merging will happen.
Constructors
Node !Size !Mean !Weight !Weight !(TDigest compression) !(TDigest compression) | Tree node |
Nil | Empty tree |
Instances
KnownNat comp => Reducer Double (TDigest comp) Source # | |
KnownNat comp => Binary (TDigest comp) Source # |
|
NFData (TDigest comp) Source # |
|
Defined in Data.TDigest.Tree.Internal | |
KnownNat comp => Monoid (TDigest comp) Source # | |
KnownNat comp => Semigroup (TDigest comp) Source # | |
Show (TDigest compression) Source # | |
HasHistogram (TDigest comp) Maybe Source # | |
But*, the benefit vs. code explosion is not yet worth.
totalWeight :: forall (comp :: Nat). TDigest comp -> Weight Source #
Total count of samples.
>>>
totalWeight (tdigest [1..100] :: TDigest 5)
100.0
minimumValue :: forall (comp :: Nat). 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 :: forall (comp :: Nat). TDigest comp -> Mean Source #
Center of right-most centroid. Note: may be different than max element inserted.
>>>
maximumValue (tdigest [1..100] :: TDigest 3)
99.0
emptyTDigest :: forall (comp :: Nat). TDigest comp Source #
combineDigest :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp -> TDigest comp Source #
insertCentroid :: forall (comp :: Nat). KnownNat comp => Centroid -> TDigest comp -> TDigest comp Source #
node :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp Source #
Constructor which calculates size and total weight.
balanceR :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp Source #
Balance after right insertion.
balanceL :: forall (comp :: Nat). Mean -> Weight -> TDigest comp -> TDigest comp -> TDigest comp Source #
Balance after left insertion.
node' :: forall (comp :: Nat). Int -> Mean -> Weight -> Weight -> TDigest comp -> TDigest comp -> TDigest comp Source #
Alias to Node
combinedCentroid :: Mean -> Weight -> Mean -> Weight -> Centroid Source #
Add two weighted means together.
Calculate the threshold, i.e. maximum weight of centroid.
compress :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp Source #
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
and bigger than relMaxSize
* compabsMaxSize
.
forceCompress :: forall (comp :: Nat). KnownNat comp => TDigest comp -> TDigest comp Source #
Perform compression, even if current size says it's not necessary.
relMaxSize :: Int Source #
Relative size parameter. Hard-coded value: 25.
absMaxSize :: Int Source #
Absolute size parameter. Hard-coded value: 1000.
validate :: forall (comp :: Nat). TDigest comp -> Either String (TDigest comp) Source #
Check various invariants in the TDigest
tree.
Insert single value into TDigest
.
singleton :: forall (comp :: Nat). KnownNat comp => Double -> TDigest comp Source #
Make a TDigest
of a single data point.
>>>
:set -XDataKinds