Stability | experimental |
---|---|
Maintainer | Alexey Khudyakov <alexey.skladnoy@gmail.com> |
Binning algorithms. This is mapping from set of interest to integer indices and approximate reverse.
- class Bin b where
- class Bin b => Bin1D b where
- binsList :: b -> [BinValue b]
- binsListRange :: b -> [(BinValue b, BinValue b)]
- class Indexable a where
- class Indexable2D a where
- data BinI = BinI !Int !Int
- binI0 :: Int -> BinI
- data BinInt
- binInt :: Int -> Int -> Int -> BinInt
- newtype BinIx i = BinIx {}
- binIx :: Indexable i => i -> i -> BinIx i
- data BinF f
- binF :: RealFrac f => f -> Int -> f -> BinF f
- binFn :: RealFrac f => f -> f -> f -> BinF f
- binI2binF :: RealFrac f => BinI -> BinF f
- scaleBinF :: RealFrac f => f -> f -> BinF f -> BinF f
- data BinD
- binD :: Double -> Int -> Double -> BinD
- binDn :: Double -> Double -> Double -> BinD
- binI2binD :: BinI -> BinD
- scaleBinD :: Double -> Double -> BinD -> BinD
- data LogBinD
- logBinD :: Double -> Int -> Double -> LogBinD
- data Bin2D binX binY = Bin2D !binX !binY
- (><) :: binX -> binY -> Bin2D binX binY
- nBins2D :: (Bin bx, Bin by) => Bin2D bx by -> (Int, Int)
- toIndex2D :: (Bin binX, Bin binY) => Bin2D binX binY -> Int -> (Int, Int)
- binX :: Bin2D bx by -> bx
- binY :: Bin2D bx by -> by
- fmapBinX :: (Bin bx, Bin bx') => (bx -> bx') -> Bin2D bx by -> Bin2D bx' by
- fmapBinY :: (Bin by, Bin by') => (by -> by') -> Bin2D bx by -> Bin2D bx by'
- data BinIx2D i
- binIx2D :: Indexable2D i => i -> i -> BinIx2D i
Type classes
Abstract binning algorithm. It provides way to map some values onto continous range of integer values starting from zero.
Following invariant is expected to hold:
toIndex . fromIndex == id
Reverse is not nessearily true.
class Bin b => Bin1D b whereSource
One dimensional binning algorithm. It means that bin values have some inherent ordering. For example all binning algorithms for real numbers could be members or this type class whereas binning algorithms for R^2 could not.
Indexable is value which could be converted to and from Int without information loss.
Always true
deindex . index = id
Only if Int is in range
index . deindex = id
class Indexable2D a whereSource
This type class is same as Indexable but for 2D values.
index2D :: a -> (Int, Int)Source
Convert value to index
deindex2D :: (Int, Int) -> aSource
Convert index to value
(Indexable a, Indexable b) => Indexable2D (a, b) |
Bin types
Integer bins
Simple binning algorithm which map continous range of bins onto indices. Each number correcsponds to different bin
Integer bins with non-1 size
Integer bins with size which differ from 1.
Indexed bins
Binning for indexable values
Floating point bins
Floaintg point bins with equal sizes.
Create bins.
Create bins. Note that actual upper bound can differ from specified.
scaleBinF :: RealFrac f => f -> f -> BinF f -> BinF fSource
'scaleBinF a b' scales BinF using linear transform 'a+b*x'
Specialized for Double
Floaintg point bins with equal sizes. If you work with Doubles this data type should be used instead of BinF.
Create bins.
Create bins. Note that actual upper bound can differ from specified.
scaleBinD :: Double -> Double -> BinD -> BinDSource
'scaleBinF a b' scales BinF using linear transform 'a+b*x'
Log scale point
2D bins
2D bins. binX is binning along X axis and binY is one along Y axis.
Bin2D !binX !binY |
nBins2D :: (Bin bx, Bin by) => Bin2D bx by -> (Int, Int)Source
2-dimensional size of binning algorithm
fmapBinX :: (Bin bx, Bin bx') => (bx -> bx') -> Bin2D bx by -> Bin2D bx' bySource
Apply function to X binning algorithm. If new binning algorithm have different number of bins will fail.
fmapBinY :: (Bin by, Bin by') => (by -> by') -> Bin2D bx by -> Bin2D bx by'Source
Apply function to Y binning algorithm. If new binning algorithm have different number of bins will fail.
2D indexed bins
Binning for 2D indexable value
(Read i, Indexable2D i) => Read (BinIx2D i) | |
(Show i, Indexable2D i) => Show (BinIx2D i) | |
Indexable2D i => Bin (BinIx2D i) |
binIx2D :: Indexable2D i => i -> i -> BinIx2D iSource
Construct indexed bin