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 |
Data.Histogram.Bin.Classes
Description
Type classes for binning algorithms. This is mapping from set of interest to integer indices and approximate reverse.
Synopsis
- 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
Methods
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)
Instances
Bin LogBinD Source # | |
Bin BinInt Source # | |
Bin BinI Source # | |
Bin BinD Source # | |
RealFrac f => Bin (BinF f) Source # | |
Enum a => Bin (BinEnum a) Source # | |
Defined in Data.Histogram.Bin.BinEnum | |
Bin b => Bin (BinPermute b) Source # | |
Defined in Data.Histogram.Bin.Extra Associated Types type BinValue (BinPermute b) :: * Source # Methods toIndex :: BinPermute b -> BinValue (BinPermute b) -> Int Source # fromIndex :: BinPermute b -> Int -> BinValue (BinPermute b) Source # nBins :: BinPermute b -> Int Source # inRange :: BinPermute b -> BinValue (BinPermute b) -> Bool Source # | |
Enum2D i => Bin (BinEnum2D i) Source # | |
Defined in Data.Histogram.Bin.Extra | |
Bin bin => Bin (MaybeBin bin) Source # | |
Defined in Data.Histogram.Bin.MaybeBin | |
(Vector v a, Ord a, Fractional a) => Bin (BinVarG v a) Source # | |
Defined in Data.Histogram.Bin.BinVar | |
(Bin binX, Bin binY) => Bin (Bin2D binX binY) Source # | |
Defined in Data.Histogram.Bin.Bin2D |
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
Minimal complete definition
Instances
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.
Minimal complete definition
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.
Instances
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 # | |
Defined in Data.Histogram.Bin.Extra Methods binInterval :: BinPermute b -> Int -> (BinValue (BinPermute b), BinValue (BinPermute b)) Source # binsList :: Vector v (BinValue (BinPermute b), BinValue (BinPermute b)) => BinPermute b -> v (BinValue (BinPermute b), BinValue (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
Minimal complete definition
Methods
lowerLimit :: b -> BinValue b Source #
Minimal accepted value of histogram
upperLimit :: b -> BinValue b Source #
Maximal accepted value of histogram
Instances
Bin1D LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD | |
Bin1D BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt | |
Bin1D BinI Source # | |
Defined in Data.Histogram.Bin.BinI | |
Bin1D BinD Source # | |
Defined in Data.Histogram.Bin.BinF | |
RealFrac f => Bin1D (BinF f) Source # | |
Defined in Data.Histogram.Bin.BinF | |
(Enum a, Ord a) => Bin1D (BinEnum a) Source # | |
Defined in Data.Histogram.Bin.BinEnum | |
(Vector v a, Ord a, Fractional a) => Bin1D (BinVarG v a) Source # | |
Defined in Data.Histogram.Bin.BinVar |
class Bin b => SliceableBin b where Source #
Binning algorithm which support slicing.
Minimal complete definition
Methods
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.
Instances
SliceableBin LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD | |
SliceableBin BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt | |
SliceableBin BinI Source # | |
Defined in Data.Histogram.Bin.BinI | |
SliceableBin BinD Source # | |
Defined in Data.Histogram.Bin.BinF | |
RealFrac f => SliceableBin (BinF f) Source # | |
Defined in Data.Histogram.Bin.BinF | |
(Enum a, Ord a) => SliceableBin (BinEnum a) Source # | |
Defined in Data.Histogram.Bin.BinEnum | |
(Vector v a, Ord a, Fractional a) => SliceableBin (BinVarG v a) Source # | |
Defined in Data.Histogram.Bin.BinVar |
Arguments
:: 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.
Minimal complete definition
Methods
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.
Instances
MergeableBin LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD Methods unsafeMergeBins :: CutDirection -> Int -> LogBinD -> LogBinD Source # | |
MergeableBin BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt Methods unsafeMergeBins :: CutDirection -> Int -> BinInt -> BinInt Source # | |
MergeableBin BinD Source # | |
Defined in Data.Histogram.Bin.BinF Methods unsafeMergeBins :: CutDirection -> Int -> BinD -> BinD Source # | |
RealFrac f => MergeableBin (BinF f) Source # | |
Defined in Data.Histogram.Bin.BinF Methods unsafeMergeBins :: CutDirection -> Int -> BinF f -> BinF f Source # |
data CutDirection Source #
How index should be dropped
Instances
Data CutDirection Source # | |
Defined in Data.Histogram.Bin.Classes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CutDirection -> c CutDirection # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CutDirection # toConstr :: CutDirection -> Constr # dataTypeOf :: CutDirection -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CutDirection) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CutDirection) # gmapT :: (forall b. Data b => b -> b) -> CutDirection -> CutDirection # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CutDirection -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CutDirection -> r # gmapQ :: (forall d. Data d => d -> u) -> CutDirection -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CutDirection -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CutDirection -> m CutDirection # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CutDirection -> m CutDirection # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CutDirection -> m CutDirection # | |
Show CutDirection Source # | |
Defined in Data.Histogram.Bin.Classes Methods showsPrec :: Int -> CutDirection -> ShowS # show :: CutDirection -> String # showList :: [CutDirection] -> ShowS # | |
Generic CutDirection Source # | |
Defined in Data.Histogram.Bin.Classes Associated Types type Rep CutDirection :: * -> * # | |
type Rep CutDirection Source # | |
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
Minimal complete definition
Instances
VariableBin LogBinD Source # | |
VariableBin BinInt Source # | |
VariableBin BinI Source # | |
VariableBin BinD Source # | |
RealFrac f => VariableBin (BinF f) Source # | |
VariableBin b => VariableBin (BinPermute b) Source # | |
Defined in Data.Histogram.Bin.Extra Methods binSizeN :: BinPermute b -> Int -> BinValue (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.
Instances
UniformBin BinInt Source # | |
UniformBin BinI Source # | |
UniformBin BinD Source # | |
RealFrac f => UniformBin (BinF f) Source # | |
UniformBin b => UniformBin (BinPermute b) Source # | |
Defined in Data.Histogram.Bin.Extra Methods binSize :: BinPermute b -> BinValue (BinPermute b) Source # |
Conversion
class (Bin b, Bin b') => ConvertBin b b' where Source #
Class for conversion between binning algorithms.
Minimal complete definition