histogram-fill-0.2.0: Library for histograms creation.

Stabilityexperimental
MaintainerAlexey Khudyakov <alexey.skladnoy@gmail.com>

Data.Histogram

Contents

Description

Immutable histograms.

Synopsis

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.

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

bins :: Histogram bin a -> binSource

Histogram bins

histData :: Histogram bin a -> Vector aSource

Histogram data as vector

underflows :: Histogram bin a -> Maybe aSource

Number of underflows

overflows :: Histogram bin a -> Maybe aSource

Number of overflows

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 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.

histZip :: (Bin bin, Eq bin, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Histogram bin a -> Histogram bin b -> Histogram bin cSource

Zip two histograms together. Bins of histograms must be equal otherwise error will be called.