histogram-fill-0.8.5.0: Library for histograms creation.

CopyrightCopyright (c) 2011 Alexey Khudyakov <alexey.skladnoy@gmail.com>
LicenseBSD3
MaintainerAlexey Khudyakov <alexey.skladnoy@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

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 where #

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

Minimal complete definition

toIndex, fromIndex, nBins

Associated Types

type BinValue b #

Type of value to bin

Methods

toIndex :: b -> BinValue b -> Int #

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 #

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 -> Int #

Total number of bins. Must be non-negative.

inRange :: b -> BinValue b -> Bool #

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

Instances

Bin LogBinD # 
Bin BinInt # 

Associated Types

type BinValue BinInt :: * #

Bin BinI # 

Associated Types

type BinValue BinI :: * #

Bin BinD # 

Associated Types

type BinValue BinD :: * #

RealFrac f => Bin (BinF f) # 

Associated Types

type BinValue (BinF f) :: * #

Methods

toIndex :: BinF f -> BinValue (BinF f) -> Int #

fromIndex :: BinF f -> Int -> BinValue (BinF f) #

nBins :: BinF f -> Int #

inRange :: BinF f -> BinValue (BinF f) -> Bool #

Enum a => Bin (BinEnum a) # 

Associated Types

type BinValue (BinEnum a) :: * #

Bin b => Bin (BinPermute b) # 

Associated Types

type BinValue (BinPermute b) :: * #

Enum2D i => Bin (BinEnum2D i) # 

Associated Types

type BinValue (BinEnum2D i) :: * #

Bin bin => Bin (MaybeBin bin) # 

Associated Types

type BinValue (MaybeBin bin) :: * #

Methods

toIndex :: MaybeBin bin -> BinValue (MaybeBin bin) -> Int #

fromIndex :: MaybeBin bin -> Int -> BinValue (MaybeBin bin) #

nBins :: MaybeBin bin -> Int #

inRange :: MaybeBin bin -> BinValue (MaybeBin bin) -> Bool #

(Vector v a, Ord a, Fractional a) => Bin (BinVarG v a) # 

Associated Types

type BinValue (BinVarG v a) :: * #

Methods

toIndex :: BinVarG v a -> BinValue (BinVarG v a) -> Int #

fromIndex :: BinVarG v a -> Int -> BinValue (BinVarG v a) #

nBins :: BinVarG v a -> Int #

inRange :: BinVarG v a -> BinValue (BinVarG v a) -> Bool #

(Bin binX, Bin binY) => Bin (Bin2D binX binY) # 

Associated Types

type BinValue (Bin2D binX binY) :: * #

Methods

toIndex :: Bin2D binX binY -> BinValue (Bin2D binX binY) -> Int #

fromIndex :: Bin2D binX binY -> Int -> BinValue (Bin2D binX binY) #

nBins :: Bin2D binX binY -> Int #

inRange :: Bin2D binX binY -> BinValue (Bin2D binX binY) -> Bool #

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

Return vector of bin centers

Approximate equality

class Bin b => BinEq b where #

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

binEq

Methods

binEq :: b -> b -> Bool #

Approximate equality

Instances

BinEq LogBinD # 

Methods

binEq :: LogBinD -> LogBinD -> Bool #

BinEq BinInt # 

Methods

binEq :: BinInt -> BinInt -> Bool #

BinEq BinI # 

Methods

binEq :: BinI -> BinI -> Bool #

BinEq BinD #

Equality is up to 3e-11 (2/3th of digits)

Methods

binEq :: BinD -> BinD -> Bool #

RealFloat f => BinEq (BinF f) #

Equality is up to 2/3th of digits

Methods

binEq :: BinF f -> BinF f -> Bool #

Enum a => BinEq (BinEnum a) # 

Methods

binEq :: BinEnum a -> BinEnum a -> Bool #

BinEq bin => BinEq (MaybeBin bin) # 

Methods

binEq :: MaybeBin bin -> MaybeBin bin -> Bool #

(Vector v a, Vector v Bool, Ord a, Fractional a) => BinEq (BinVarG v a) #

Equality is up to 3e-11 (2/3th of digits)

Methods

binEq :: BinVarG v a -> BinVarG v a -> Bool #

(BinEq bx, BinEq by) => BinEq (Bin2D bx by) # 

Methods

binEq :: Bin2D bx by -> Bin2D bx by -> Bool #

1D bins

class (Bin b, Ord (BinValue b)) => IntervalBin b where #

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

Minimal complete definition

binInterval

Methods

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

Interval for n'th bin

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

List of all bins. Could be overridden for efficiency.

Instances

IntervalBin LogBinD # 
IntervalBin BinInt # 
IntervalBin BinI # 
IntervalBin BinD # 
RealFrac f => IntervalBin (BinF f) # 

Methods

binInterval :: BinF f -> Int -> (BinValue (BinF f), BinValue (BinF f)) #

binsList :: Vector v (BinValue (BinF f), BinValue (BinF f)) => BinF f -> v (BinValue (BinF f), BinValue (BinF f)) #

(Enum a, Ord a) => IntervalBin (BinEnum a) # 
IntervalBin b => IntervalBin (BinPermute b) # 
(Vector v a, Ord a, Fractional a) => IntervalBin (BinVarG v a) # 

Methods

binInterval :: BinVarG v a -> Int -> (BinValue (BinVarG v a), BinValue (BinVarG v a)) #

binsList :: Vector v (BinValue (BinVarG v a), BinValue (BinVarG v a)) => BinVarG v a -> v (BinValue (BinVarG v a), BinValue (BinVarG v a)) #

class IntervalBin b => Bin1D b where #

IntervalBin which domain is single finite interval

Minimal complete definition

lowerLimit, upperLimit

Methods

lowerLimit :: b -> BinValue b #

Minimal accepted value of histogram

upperLimit :: b -> BinValue b #

Maximal accepted value of histogram

class Bin b => SliceableBin b where #

Binning algorithm which support slicing.

Minimal complete definition

unsafeSliceBin

Methods

unsafeSliceBin :: Int -> Int -> b -> b #

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

Instances

SliceableBin LogBinD # 

Methods

unsafeSliceBin :: Int -> Int -> LogBinD -> LogBinD #

SliceableBin BinInt # 

Methods

unsafeSliceBin :: Int -> Int -> BinInt -> BinInt #

SliceableBin BinI # 

Methods

unsafeSliceBin :: Int -> Int -> BinI -> BinI #

SliceableBin BinD # 

Methods

unsafeSliceBin :: Int -> Int -> BinD -> BinD #

RealFrac f => SliceableBin (BinF f) # 

Methods

unsafeSliceBin :: Int -> Int -> BinF f -> BinF f #

(Enum a, Ord a) => SliceableBin (BinEnum a) # 

Methods

unsafeSliceBin :: Int -> Int -> BinEnum a -> BinEnum a #

(Vector v a, Ord a, Fractional a) => SliceableBin (BinVarG v a) # 

Methods

unsafeSliceBin :: Int -> Int -> BinVarG v a -> BinVarG v a #

sliceBin #

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 #

Bin which support rebinning.

Minimal complete definition

unsafeMergeBins

Methods

unsafeMergeBins :: CutDirection -> Int -> b -> b #

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 #

How index should be dropped

Constructors

CutLower

Drop bins with smallest index

CutHigher

Drop bins with bigger index

Instances

Data CutDirection # 

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 # 
Generic CutDirection # 

Associated Types

type Rep CutDirection :: * -> * #

type Rep CutDirection # 
type Rep CutDirection = D1 (MetaData "CutDirection" "Data.Histogram.Bin.Classes" "histogram-fill-0.8.5.0-HkBrjr8b6DfFIp5Ksrk6Iy" False) ((:+:) (C1 (MetaCons "CutLower" PrefixI False) U1) (C1 (MetaCons "CutHigher" PrefixI False) U1))

mergeBins :: MergeableBin b => CutDirection -> Int -> b -> b #

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 #

1D binning algorithms with variable bin size

Minimal complete definition

binSizeN

Methods

binSizeN :: b -> Int -> BinValue b #

Size of n'th bin.

Instances

class VariableBin b => UniformBin b where #

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 b #

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

Conversion

class (Bin b, Bin b') => ConvertBin b b' where #

Class for conversion between binning algorithms.

Minimal complete definition

convertBin

Methods

convertBin :: b -> b' #

Convert bins

Instances

(Bin1D b, Vector v (BinValue b), Vector v Bool, (~) * a (BinValue b), Fractional a) => ConvertBin b (BinVarG v a) # 

Methods

convertBin :: b -> BinVarG v a #