Copyright | Copyright (c) 2011 Alexey Khudyakov <alexey.skladnoy@gmail.com> |
---|---|
License | BSD3 |
Maintainer | Alexey Khudyakov <alexey.skladnoy@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Type classes for binning algorithms. This is mapping from set of interest to integer indices and approximate reverse.
- class Bin b where
- type BinValue b
- binsCenters :: (Bin b, Vector v (BinValue b)) => b -> v (BinValue b)
- class Bin b => BinEq b where
- class (Bin b, Ord (BinValue b)) => IntervalBin b where
- class IntervalBin b => Bin1D b where
- class Bin b => SliceableBin b where
- sliceBin :: SliceableBin b => Int -> Int -> b -> b
- class Bin b => MergeableBin b where
- data CutDirection
- mergeBins :: MergeableBin b => CutDirection -> Int -> b -> b
- class Bin b => VariableBin b where
- class VariableBin b => UniformBin b where
- class (Bin b, Bin b') => ConvertBin b b' where
Bin type class
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
toIndex :: b -> BinValue b -> Int Source #
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 b Source #
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.
Total number of bins. Must be non-negative.
inRange :: b -> BinValue b -> Bool Source #
Check whether value in range. Have default implementation. Should satisfy: inRange b x ⇔ toIndex b x ∈ [0,nBins b)
Bin LogBinD Source # | |
Bin BinInt Source # | |
Bin BinI Source # | |
Bin BinD Source # | |
RealFrac f => Bin (BinF f) Source # | |
Enum a => Bin (BinEnum a) Source # | |
Bin b => Bin (BinPermute b) Source # | |
Enum2D i => Bin (BinEnum2D i) Source # | |
Bin bin => Bin (MaybeBin bin) Source # | |
(Vector v a, Ord a, Fractional a) => Bin (BinVarG v a) Source # | |
(Bin binX, Bin binY) => Bin (Bin2D binX binY) Source # | |
binsCenters :: (Bin b, Vector v (BinValue b)) => b -> v (BinValue b) Source #
Return vector of bin centers
Approximate equality
class Bin b => BinEq b where Source #
Approximate equality for bins. It's nessesary to define approximate equality since exact equality is ill defined for bins which work with floating point data. It's not safe to compare floating point numbers for exact equality
BinEq LogBinD Source # | |
BinEq BinInt Source # | |
BinEq BinI Source # | |
BinEq BinD Source # | Equality is up to 3e-11 (2/3th of digits) |
RealFloat f => BinEq (BinF f) Source # | Equality is up to 2/3th of digits |
Enum a => BinEq (BinEnum a) Source # | |
BinEq bin => BinEq (MaybeBin bin) Source # | |
(Vector v a, Vector v Bool, Ord a, Fractional a) => BinEq (BinVarG v a) Source # | Equality is up to 3e-11 (2/3th of digits) |
(BinEq bx, BinEq by) => BinEq (Bin2D bx by) Source # | |
1D bins
class (Bin b, Ord (BinValue b)) => IntervalBin b where Source #
For binning algorithms which work with bin values which have some natural ordering and every bin is continous interval.
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.
IntervalBin LogBinD Source # | |
IntervalBin BinInt Source # | |
IntervalBin BinI Source # | |
IntervalBin BinD Source # | |
RealFrac f => IntervalBin (BinF f) Source # | |
(Enum a, Ord a) => IntervalBin (BinEnum a) Source # | |
IntervalBin b => IntervalBin (BinPermute b) Source # | |
(Vector v a, Ord a, Fractional a) => IntervalBin (BinVarG v a) Source # | |
class IntervalBin b => Bin1D b where Source #
IntervalBin
which domain is single finite interval
lowerLimit :: b -> BinValue b Source #
Minimal accepted value of histogram
upperLimit :: b -> BinValue b Source #
Maximal accepted value of histogram
class Bin b => SliceableBin b where Source #
Binning algorithm which support slicing.
unsafeSliceBin :: Int -> Int -> b -> b Source #
Slice bin by indices. This function doesn't perform any checks
and may produce invalid bin. Use sliceBin
instead.
SliceableBin LogBinD Source # | |
SliceableBin BinInt Source # | |
SliceableBin BinI Source # | |
SliceableBin BinD Source # | |
RealFrac f => SliceableBin (BinF f) Source # | |
(Enum a, Ord a) => SliceableBin (BinEnum a) Source # | |
(Vector v a, Ord a, Fractional a) => SliceableBin (BinVarG v a) Source # | |
:: SliceableBin b | |
=> Int | Index of first bin |
-> Int | Index of last bin |
-> b | |
-> b |
Slice bin using indices
class Bin b => MergeableBin b where Source #
Bin which support rebinning.
unsafeMergeBins :: CutDirection -> Int -> b -> b Source #
N
consecutive bins are joined into single bin. If number of
bins isn't multiple of N
remaining bins with highest or
lowest index are dropped. This function doesn't do any
checks. Use mergeBins
instead.
data CutDirection Source #
How index should be dropped
mergeBins :: MergeableBin b => CutDirection -> Int -> b -> b Source #
N
consecutive bins are joined into single bin. If number of
bins isn't multiple of N
remaining bins with highest or lowest
index are dropped. If N
is larger than number of bins all bins
are merged into single one.
Sizes of bin
class Bin b => VariableBin b where Source #
1D binning algorithms with variable bin size
VariableBin LogBinD Source # | |
VariableBin BinInt Source # | |
VariableBin BinI Source # | |
VariableBin BinD Source # | |
RealFrac f => VariableBin (BinF f) Source # | |
VariableBin b => VariableBin (BinPermute b) Source # | |
VariableBin bin => VariableBin (MaybeBin bin) Source # | |
(Vector v a, Ord a, Fractional a) => VariableBin (BinVarG v a) Source # | |
class VariableBin b => UniformBin b where Source #
1D binning algorithms with constant size bins. Constant sized bins could be thought as specialization of variable-sized bins therefore a superclass constraint.
UniformBin BinInt Source # | |
UniformBin BinI Source # | |
UniformBin BinD Source # | |
RealFrac f => UniformBin (BinF f) Source # | |
UniformBin b => UniformBin (BinPermute b) Source # | |
Conversion
class (Bin b, Bin b') => ConvertBin b b' where Source #
Class for conversion between binning algorithms.
convertBin :: b -> b' Source #
Convert bins