Safe Haskell | None |
---|---|
Language | Haskell2010 |
NumHask.Space.Histogram
Description
A histogram, if you squint, is a series of contiguous Range
s, annotated with values.
Synopsis
- data Histogram = Histogram {}
- data DealOvers
- fill :: Foldable f => [Double] -> f Double -> Histogram
- cutI :: Ord a => Vector a -> a -> Int
- regular :: Int -> [Double] -> Histogram
- makeRects :: DealOvers -> Histogram -> [Rect Double]
- regularQuantiles :: Double -> [Double] -> [Double]
- quantileFold :: [Double] -> [Double] -> [Double]
- freq :: Histogram -> Histogram
- average :: Foldable f => f Double -> Double
- quantiles :: Foldable f => Int -> f Double -> [Double]
- quantile :: Foldable f => Double -> f Double -> Double
Documentation
This Histogram is a list of contiguous boundaries (a boundary being the lower edge of one bucket and the upper edge of another), and a value (usually a count) for each bucket, represented here as a map
Overs and Unders are contained in key = 0 and key = length cuts Intervals are defined as (l,u]
Whether or not to ignore unders and overs. If overs and unders are dealt with, IncludeOvers supplies an assumed width for the outer buckets.
Constructors
IgnoreOvers | |
IncludeOvers Double |
fill :: Foldable f => [Double] -> f Double -> Histogram Source #
Fill a Histogram using pre-specified cuts
>>>
fill [0,50,100] [0..99]
Histogram {cuts = [0.0,50.0,100.0], values = fromList [(1,50.0),(2,50.0)]}
cutI :: Ord a => Vector a -> a -> Int Source #
find the index of the bucket the value is contained in.
regular :: Int -> [Double] -> Histogram Source #
Make a histogram using n equally spaced cuts over the entire range of the data
>>>
regular 4 [0..100]
Histogram {cuts = [0.0,25.0,50.0,75.0,100.0], values = fromList [(1,25.0),(2,25.0),(3,25.0),(4,25.0),(5,1.0)]}
makeRects :: DealOvers -> Histogram -> [Rect Double] Source #
Transform a Histogram to Rects
>>>
makeRects IgnoreOvers (regular 4 [0..100])
[Rect 0.0 25.0 0.0 0.25,Rect 25.0 50.0 0.0 0.25,Rect 50.0 75.0 0.0 0.25,Rect 75.0 100.0 0.0 0.25]
regularQuantiles :: Double -> [Double] -> [Double] Source #
approx regular n-quantiles
>>>
regularQuantiles 4 [0..100]
[0.0,24.75,50.0,75.25,100.0]
freq :: Histogram -> Histogram Source #
normalize a histogram
\h -> sum (values $ freq h) == one
>>>
freq $ fill [0,50,100] [0..99]
Histogram {cuts = [0.0,50.0,100.0], values = fromList [(1,0.5),(2,0.5)]}