Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- class Affine f => HasHistogram a f | a -> f where
- data HistBin = HistBin {}
- median :: HasHistogram a f => a -> f Double
- quantile :: HasHistogram a f => Double -> a -> f Double
- mean :: HasHistogram a f => a -> f Double
- variance :: HasHistogram a f => a -> f Double
- stddev :: HasHistogram a f => a -> f Double
- cdf :: HasHistogram a f => Double -> a -> Double
- icdf :: HasHistogram a f => Double -> a -> f Double
- class Traversable t => Affine t where
Histogram
class Affine f => HasHistogram a f | a -> f where Source #
Types from which we can extract histogram.
Histogram bin
Quantiles
quantile :: HasHistogram a f => Double -> a -> f Double Source #
Calculate quantile of a specific value.
Mean & variance
As we have "full" histogram, we can calculate other statistical variables.
mean :: HasHistogram a f => a -> f Double Source #
Mean.
>>>
mean (Tree.tdigest [1..100] :: Tree.TDigest 10)
Just 50.5
Note: if you only need the mean, calculate it directly.
variance :: HasHistogram a f => a -> f Double Source #
Variance.
stddev :: HasHistogram a f => a -> f Double Source #
Standard deviation, square root of variance.
CDF
cdf :: HasHistogram a f => Double -> a -> Double Source #
Cumulative distribution function.
Note: if this is the only thing you need, it's more efficient to count this directly.
Affine
class Traversable t => Affine t where Source #
Affine containers, i.e. containing at most 1 element
This class doesn't have traverse
analogie
as it would require using Pointed
which is disputed type class.
traverseAff :: Pointed f => (a -> f b) -> t a -> f (t b)