statistics-0.10.2.0: A library of statistical types, data, and functions

Portability | portable
Stability | experimental
Maintainer | bos@serpentine.com
Safe Haskell | None

Statistics.Sample.Histogram

Contents

- Building blocks

Description

Functions for computing histograms of sample data.

Synopsis

- histogram :: (Vector v0 Double, Vector v1 Double, Num b, Vector v1 b) => Int -> v0 Double -> (v1 Double, v1 b)
- histogram_ :: (Num b, RealFrac a, Vector v0 a, Vector v1 b) => Int -> a -> a -> v0 a -> v1 b
- range :: Vector v Double => Int -> v Double -> (Double, Double)

# Documentation

histogram

Arguments

:: (Vector v0 Double, Vector v1 Double, Num b, Vector v1 b) |
=> Int | Number of bins (must be positive).
-> v0 Double | Sample data (cannot be empty).
-> (v1 Double, v1 b) |

O(n) Compute a histogram over a data set.

The result consists of a pair of vectors:

- The lower bound of each interval. * The number of samples within the interval.

Interval (bin) sizes are uniform, and the upper and lower bounds are chosen automatically using the `range` function. To specify these parameters directly, use the `histogram_` function.

# Building blocks

histogram_

Arguments

:: (Num b, RealFrac a, Vector v0 a, Vector v1 b) |
=> Int | Number of bins. This value must be positive. A zero or negative value will cause an error.
-> a | Lower bound on interval range. Sample data less than this will cause an error.
-> a | Upper bound on interval range. This value must not be less than the lower bound. Sample data that falls above the upper bound will cause an error.
-> v0 a | Sample data.
-> v1 b |

O(n) Compute a histogram over a data set.

Interval (bin) sizes are uniform, based on the supplied upper and lower bounds.

range

Arguments

:: Vector v Double |
=> Int | Number of bins (must be positive).
-> v Double | Sample data (cannot be empty).
-> (Double, Double) |

O(n) Compute decent defaults for the lower and upper bounds of a histogram, based on the desired number of bins and the range of the sample data.

The upper and lower bounds used are `(lo-d, hi+d)`, where

    d = (maximum sample - minimum sample) / ((bins - 1) * 2)