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