Stability | experimental |
---|---|
Maintainer | Alexey Khudyakov <alexey.skladnoy@gmail.com> |
Immutable histograms.
- type Histogram bin a = Histogram Vector bin a
- module Data.Histogram.Bin
- histogram :: (Unbox a, Bin bin) => bin -> Vector a -> Histogram bin a
- histogramUO :: (Unbox a, Bin bin) => bin -> Maybe (a, a) -> Vector a -> Histogram bin a
- readHistogram :: (Read bin, Read a, Bin bin, Unbox a) => String -> Histogram bin a
- readFileHistogram :: (Read bin, Read a, Bin bin, Unbox a) => FilePath -> IO (Histogram bin a)
- bins :: Histogram bin a -> bin
- histData :: Histogram bin a -> Vector a
- underflows :: Histogram bin a -> Maybe a
- overflows :: Histogram bin a -> Maybe a
- outOfRange :: Histogram bin a -> Maybe (a, a)
- asList :: (Unbox a, Bin bin) => Histogram bin a -> [(BinValue bin, a)]
- asVector :: (Bin bin, Unbox a, Unbox (BinValue bin), Unbox (BinValue bin, a)) => Histogram bin a -> Vector (BinValue bin, a)
- sliceByIx :: (Bin1D bin, Unbox a) => Int -> Int -> Histogram bin a -> Histogram bin a
- sliceByVal :: (Bin1D bin, Unbox a) => BinValue bin -> BinValue bin -> Histogram bin a -> Histogram bin a
- sliceX :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bX, Histogram bY a)]
- sliceY :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bY, Histogram bX a)]
- histMap :: (Unbox a, Unbox b) => (a -> b) -> Histogram bin a -> Histogram bin b
- histMapBin :: (Bin bin, Bin bin') => (bin -> bin') -> Histogram bin a -> Histogram bin' a
- histZip :: (Bin bin, Eq bin, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Histogram bin a -> Histogram bin b -> Histogram bin c
- histZipSafe :: (Bin bin, Eq bin, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Histogram bin a -> Histogram bin b -> Maybe (Histogram bin c)
Immutable histogram
Data type
type Histogram bin a = Histogram Vector bin aSource
Immutable histogram. Histogram consists of binning algorithm, optional number of under and overflows, and data.
module Data.Histogram.Bin
histogram :: (Unbox a, Bin bin) => bin -> Vector a -> Histogram bin aSource
Create histogram from binning algorithm and vector with data. Overflows are set to Nothing.
Number of bins and vector size must match.
histogramUO :: (Unbox a, Bin bin) => bin -> Maybe (a, a) -> Vector a -> Histogram bin aSource
Create histogram from binning algorithm and vector with data.
Number of bins and vector size must match.
Read histograms from string
readHistogram :: (Read bin, Read a, Bin bin, Unbox a) => String -> Histogram bin aSource
Convert String to histogram. Histogram do not have Read instance because of slowness of ReadP
readFileHistogram :: (Read bin, Read a, Bin bin, Unbox a) => FilePath -> IO (Histogram bin a)Source
Read histogram from file.
Accessors
underflows :: Histogram bin a -> Maybe aSource
Number of underflows
outOfRange :: Histogram bin a -> Maybe (a, a)Source
Underflows and overflows
Convert to other data types
asList :: (Unbox a, Bin bin) => Histogram bin a -> [(BinValue bin, a)]Source
Convert histogram to list.
asVector :: (Bin bin, Unbox a, Unbox (BinValue bin), Unbox (BinValue bin, a)) => Histogram bin a -> Vector (BinValue bin, a)Source
Convert histogram to vector
Slicing histogram
sliceByVal :: (Bin1D bin, Unbox a) => BinValue bin -> BinValue bin -> Histogram bin a -> Histogram bin aSource
Splitting 2D histograms
sliceX :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bX, Histogram bY a)]Source
Slice 2D histogram along X axis.
sliceY :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bY, Histogram bX a)]Source
Slice 2D histogram along Y axis. This function is fast because it does not require reallocations.
Modify histogram
histMap :: (Unbox a, Unbox b) => (a -> b) -> Histogram bin a -> Histogram bin bSource
fmap lookalike. It's not possible to create Functor instance because of class restrictions
histMapBin :: (Bin bin, Bin bin') => (bin -> bin') -> Histogram bin a -> Histogram bin' aSource
Apply function to histogram bins. Function must not change number of bins. If it does error is thrown.