Copyright | Copyright (c) 2011 Alexey Khudyakov <[email protected]> |
---|---|
License | BSD3 |
Maintainer | Alexey Khudyakov <[email protected]> |
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
- 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
- lowerLimit :: b -> BinValue b
- upperLimit :: b -> BinValue b
- class Bin b => SliceableBin b where
- unsafeSliceBin :: Int -> Int -> b -> b
- sliceBin :: SliceableBin b => Int -> Int -> b -> b
- class Bin b => MergeableBin b where
- unsafeMergeBins :: CutDirection -> Int -> b -> b
- 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
- convertBin :: b -> b'
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
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
Instances
BinEq BinD Source # | Equality is up to 3e-11 (2/3th of digits) |
BinEq BinI Source # | |
BinEq BinInt Source # | |
BinEq LogBinD Source # | |
Enum a => BinEq (BinEnum a) Source # | |
RealFloat f => BinEq (BinF f) Source # | Equality is up to 2/3th of digits |
BinEq bin => BinEq (MaybeBin bin) Source # | |
(BinEq bx, BinEq by) => BinEq (Bin2D bx by) 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) |
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 BinD Source # | |
IntervalBin BinI Source # | |
IntervalBin BinInt Source # | |
IntervalBin LogBinD Source # | |
(Enum a, Ord a) => IntervalBin (BinEnum a) Source # | |
RealFrac f => IntervalBin (BinF f) 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
Methods
lowerLimit :: b -> BinValue b Source #
Minimal accepted value of histogram
upperLimit :: b -> BinValue b Source #
Maximal accepted value of histogram
Instances
Bin1D BinD Source # | |
Defined in Data.Histogram.Bin.BinF | |
Bin1D BinI Source # | |
Defined in Data.Histogram.Bin.BinI | |
Bin1D BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt | |
Bin1D LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD | |
(Enum a, Ord a) => Bin1D (BinEnum a) Source # | |
Defined in Data.Histogram.Bin.BinEnum | |
RealFrac f => Bin1D (BinF f) Source # | |
Defined in Data.Histogram.Bin.BinF | |
(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.
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 BinD Source # | |
Defined in Data.Histogram.Bin.BinF | |
SliceableBin BinI Source # | |
Defined in Data.Histogram.Bin.BinI | |
SliceableBin BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt | |
SliceableBin LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD | |
(Enum a, Ord a) => SliceableBin (BinEnum a) Source # | |
Defined in Data.Histogram.Bin.BinEnum | |
RealFrac f => SliceableBin (BinF f) Source # | |
Defined in Data.Histogram.Bin.BinF | |
(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.
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 BinD Source # | |
Defined in Data.Histogram.Bin.BinF Methods unsafeMergeBins :: CutDirection -> Int -> BinD -> BinD Source # | |
MergeableBin BinInt Source # | |
Defined in Data.Histogram.Bin.BinInt Methods unsafeMergeBins :: CutDirection -> Int -> BinInt -> BinInt Source # | |
MergeableBin LogBinD Source # | |
Defined in Data.Histogram.Bin.LogBinD Methods unsafeMergeBins :: CutDirection -> Int -> LogBinD -> LogBinD 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 :: forall r r'. (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 # | |||||
Generic CutDirection Source # | |||||
Defined in Data.Histogram.Bin.Classes Associated Types
| |||||
Show CutDirection Source # | |||||
Defined in Data.Histogram.Bin.Classes Methods showsPrec :: Int -> CutDirection -> ShowS # show :: CutDirection -> String # showList :: [CutDirection] -> ShowS # | |||||
type Rep CutDirection Source # | |||||
Defined in Data.Histogram.Bin.Classes |
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
Instances
VariableBin BinD Source # | |
VariableBin BinI Source # | |
VariableBin BinInt Source # | |
VariableBin LogBinD 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.
Minimal complete definition
Nothing
Instances
UniformBin BinD Source # | |
UniformBin BinI Source # | |
UniformBin BinInt 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.
Instances
ConvertBin BinI BinD Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: BinI -> BinD Source # | |
ConvertBin BinI BinInt Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: BinI -> BinInt Source # | |
ConvertBin BinInt BinD Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: BinInt -> BinD Source # | |
RealFrac f => ConvertBin BinI (BinF f) Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: BinI -> BinF f Source # | |
RealFrac f => ConvertBin BinInt (BinF f) Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: BinInt -> BinF f Source # | |
(Bin1D b, Vector v (BinValue b), Vector v Bool, a ~ BinValue b, Fractional a) => ConvertBin b (BinVarG v a) Source # | |
Defined in Data.Histogram.Bin.BinVar Methods convertBin :: b -> BinVarG v a Source # | |
(ConvertBin by by', Bin bx) => ConvertBin (Bin2D bx by) (Bin2D bx by') Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: Bin2D bx by -> Bin2D bx by' Source # | |
(ConvertBin bx bx', Bin by) => ConvertBin (Bin2D bx by) (Bin2D bx' by) Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: Bin2D bx by -> Bin2D bx' by Source # | |
(ConvertBin bx bx', ConvertBin by by') => ConvertBin (Bin2D bx by) (Bin2D bx' by') Source # | |
Defined in Data.Histogram.Bin Methods convertBin :: Bin2D bx by -> Bin2D bx' by' Source # |