histogram-fill-0.2.0: Library for histograms creation.

Stabilityexperimental
MaintainerAlexey Khudyakov <alexey.skladnoy@gmail.com>

Data.Histogram.Fill

Contents

Description

Module with algorithms for histogram filling. This is pure wrapper around stateful histograms.

Synopsis

Type classes

class HistBuilder h whereSource

Histogram builder typeclass. Instance of this class contain instructions how to build histograms.

Methods

modifyIn :: (a' -> a) -> h a b -> h a' bSource

Convert input type of histogram from a to a'

modifyMaybe :: h a b -> h (Maybe a) bSource

Make input function accept value only if it's Just a.

addCut :: (a -> Bool) -> h a b -> h a bSource

Add cut to histogram. Only put value histogram if condition is true.

modifyOut :: (b -> b') -> h a b -> h a b'Source

Convert output of histogram

Histogram builders

Stateful

data HBuilderST s a b Source

Stateful histogram builder.

feedOne :: HBuilderST s a b -> a -> ST s ()Source

Put one value into histogram

freezeHBuilderST :: HBuilderST s a b -> ST s bSource

Create stateful histogram from instructions. Histograms could be filled either in the ST monad or with createHistograms

joinHBuilderST :: [HBuilderST s a b] -> HBuilderST s a [b]Source

Join list of builders into one builder

joinHBuilderSTList :: [HBuilderST s a [b]] -> HBuilderST s a [b]Source

Join list of builders into one builders

treeHBuilderST :: [HBuilderST s a b -> HBuilderST s a' b'] -> HBuilderST s a b -> HBuilderST s a' [b']Source

IO based

data HBuilderIO a b Source

Stateful histogram builder.

feedOneIO :: HBuilderIO a b -> a -> IO ()Source

Put one value into histogram

freezeHBuilderIO :: HBuilderIO a b -> IO bSource

Create stateful histogram from instructions. Histograms could be filled either in the ST monad or with createHistograms

joinHBuilderIO :: [HBuilderIO a b] -> HBuilderIO a [b]Source

Join list of builders into one builder

joinHBuilderIOList :: [HBuilderIO a [b]] -> HBuilderIO a [b]Source

Join list of builders into one builders

treeHBuilderIO :: [HBuilderIO a b -> HBuilderIO a' b'] -> HBuilderIO a b -> HBuilderIO a' [b']Source

Stateless

data HBuilder a b Source

Stateless histogram builder

joinHBuilder :: [HBuilder a b] -> HBuilder a [b]Source

Join list of builders

joinHBuilderList :: [HBuilder a [b]] -> HBuilder a [b]Source

Join list of builders

treeHBuilder :: [HBuilder a b -> HBuilder a' b'] -> HBuilder a b -> HBuilder a' [b']Source

Conversion between builders

toBuilderST :: HBuilder a b -> forall s. ST s (HBuilderST s a b)Source

toBuilderIO :: HBuilder a b -> IO (HBuilderIO a b)Source

Convert stateless builder to IO based one

builderSTtoIO :: HBuilderST RealWorld a b -> HBuilderIO a bSource

Convert ST base builder to IO based one

Fill histograms

fillBuilder :: HBuilder a b -> [a] -> bSource

Histogram constructors

Fixed weigth histograms

mkHist1Source

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> BinValue bin)

Input function

-> HBuilder a b 

Create histogram builder which take single item as input. Each item has weight 1.

mkHistSource

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> [BinValue bin])

Input function

-> HBuilder a b 

Create histogram builder which take many items as input. Each item has weight 1.

mkHistMaybeSource

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> Maybe (BinValue bin))

Input function

-> HBuilder a b 

Create histogram builder which at most one item as input. Each item has weight 1.

Weighted histograms

mkHistWgh1Source

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> (BinValue bin, val))

Input function

-> HBuilder a b 

Create histogram with weighted bin. Takes one item at time.

mkHistWghSource

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> [(BinValue bin, val)])

Input function

-> HBuilder a b 

Create histogram with weighted bin. Takes many items at time.

mkHistWghMaybeSource

Arguments

:: (Bin bin, Unbox val, Num val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> Maybe (BinValue bin, val))

Input function

-> HBuilder a b 

Create histogram with weighted bin. Takes many items at time.

Histograms with monoidal bins

mkHistMonoid1Source

Arguments

:: (Bin bin, Unbox val, Monoid val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> (BinValue bin, val))

Input function

-> HBuilder a b 

Create histogram with monoidal bins

mkHistMonoidSource

Arguments

:: (Bin bin, Unbox val, Monoid val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> [(BinValue bin, val)])

Input function

-> HBuilder a b 

Create histogram with monoidal bins. Takes many items at time.

mkHistMonoidMaybeSource

Arguments

:: (Bin bin, Unbox val, Monoid val) 
=> bin

Bin information

-> (Histogram bin val -> b)

Output function

-> (a -> Maybe (BinValue bin, val))

Input function

-> HBuilder a b 

Create histogram with monoidal bins

Auxillary functions

forceInt :: Histogram bin Int -> Histogram bin IntSource

Function used to restrict type of histrogram.

forceDouble :: Histogram bin Double -> Histogram bin DoubleSource

Function used to restrict type of histrogram.

forceFloat :: Histogram bin Float -> Histogram bin FloatSource

Function used to restrict type of histrogram.