histogram-fill-0.5.1: Library for histograms creation.

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

Data.Histogram.Bin.Classes

Contents

Description

Type classes for binning algorithms. This is mapping from set of interest to integer indices and approximate reverse.

Synopsis

Bin type class

class Bin b whereSource

This type represent some abstract data binning algorithms. It maps sets/intervals of values of type 'BinValue b' to integer indices.

Following invariant is expected to hold:

 toIndex . fromIndex == id

Associated Types

type BinValue b Source

Type of value to bin

Methods

toIndex :: b -> BinValue b -> IntSource

Convert from value to index. Function must not fail for any input and should produce out of range indices for invalid input.

fromIndex :: b -> Int -> BinValue bSource

Convert from index to value. Returned value should correspond to center of bin. Definition of center is left for definition of instance. Funtion may fail for invalid indices but encouraged not to do so.

nBins :: b -> IntSource

Total number of bins.

inRange :: b -> BinValue b -> BoolSource

Check whether value in range. Have default implementation. Should satisfy: inRange b x ⇔ toIndex b x ∈ [0,nBins b)

Instances

Bin BinI 
Bin BinInt 
Bin BinD 
Bin LogBinD 
Enum a => Bin (BinEnum a) 
RealFrac f => Bin (BinF f) 
Bin b => Bin (BinPermute b) 
Enum2D i => Bin (BinEnum2D i) 
(Bin binX, Bin binY) => Bin (Bin2D binX binY) 

binsCenters :: (Bin b, Vector v (BinValue b)) => b -> v (BinValue b)Source

Return vector of bin centers

1D bins

class Bin b => IntervalBin b whereSource

For binning algorithms which work with bin values which have some natural ordering and every bin is continous interval.

Methods

binInterval :: b -> Int -> (BinValue b, BinValue b)Source

Interval for n'th bin

binsList :: Vector v (BinValue b, BinValue b) => b -> v (BinValue b, BinValue b)Source

List of all bins. Could be overridden for efficiency.

class IntervalBin b => Bin1D b whereSource

IntervalBin which domain is single finite interval

Methods

lowerLimit :: b -> BinValue bSource

Minimal accepted value of histogram

upperLimit :: b -> BinValue bSource

Maximal accepted value of histogram

unsafeSliceBin :: Int -> Int -> b -> bSource

Slice bin by indices. This function doesn't perform any checks and may produce invalid bin

sliceBin :: Bin1D b => Int -> Int -> b -> bSource

Slice bin using indices

class Bin b => VariableBin b whereSource

1D binning algorithms with variable bin size

Methods

binSizeN :: b -> Int -> BinValue bSource

Size of n'th bin.

class VariableBin b => UniformBin b whereSource

1D binning algorithms with constant size bins. Constant sized bins could be thought as specialization of variable-sized bins therefore a superclass constraint.

Methods

binSize :: b -> BinValue bSource

Size of bin. Default implementation just uses 0th bin.

class Bin1D b => GrowBin b whereSource

Binning algorithm which allows to append and prepend bins.

Methods

zeroBin :: b -> bSource

Set number of bins to zero. By convention bins are shrinked to lower bound.

appendBin :: b -> bSource

Append one bin at upper bound

prependBin :: b -> bSource

Prepend one bin at lower bin

Conversion

class (Bin b, Bin b') => ConvertBin b b' whereSource

Class for conversion between binning algorithms.

Methods

convertBin :: b -> b'Source

Convert bins

Instances

ConvertBin BinI BinD 
ConvertBin BinInt BinD 
RealFrac f => ConvertBin BinI (BinF f) 
RealFrac f => ConvertBin BinInt (BinF f) 
(ConvertBin bx bx', ConvertBin by by') => ConvertBin (Bin2D bx by) (Bin2D bx' by') 
(ConvertBin by by', Bin bx) => ConvertBin (Bin2D bx by) (Bin2D bx by') 
(ConvertBin bx bx', Bin by) => ConvertBin (Bin2D bx by) (Bin2D bx' by)