numhask-space-0.6.1: numerical spaces

Safe HaskellNone
LanguageHaskell2010

NumHask.Space.Histogram

Description

A histogram, if you squint, is a series of contiguous ranges, annotated with values.

Synopsis

Documentation

data Histogram Source #

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

Constructors

Histogram 

Fields

Instances
Eq Histogram Source # 
Instance details

Defined in NumHask.Space.Histogram

Show Histogram Source # 
Instance details

Defined in NumHask.Space.Histogram

data DealOvers Source #

Whether or not to ignore unders and overs. If overs and unders are dealt with, IncludeOvers supplies an assumed width for the outer buckets.

fill :: Foldable f => [Double] -> f Double -> Histogram Source #

Fill a Histogram using pre-specified cuts

>>> fill [0,50,100] [1..100]
Histogram {cuts = [0.0,50.0,100.0], values = fromList [(1,50.0),(2,50.0)]}

cutI :: Ord a => [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 [(0,1.0),(1,25.0),(2,25.0),(3,25.0),(4,25.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]

quantileFold :: [Double] -> [Double] -> [Double] Source #

one-pass approximate quantiles fold

fromQuantiles :: [Double] -> [Double] -> Histogram Source #

take a specification of quantiles and make a Histogram

>>> fromQuantiles [0,0.25,0.5,0.75,1] (regularQuantiles 4 [0..100])
Histogram {cuts = [0.0,24.75,50.0,75.25,100.0], values = fromList [(1,0.25),(2,0.25),(3,0.25),(4,0.25)]}

freq :: Histogram -> Histogram Source #

normalize a histogram so that sum values = one

>>> freq $ fill [0,50,100] [1..100]
Histogram {cuts = [0.0,50.0,100.0], values = fromList [(1,0.5),(2,0.5)]}