Copyright | Copyright (c) 2012-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 8.0.1
This module computes the histogram by the specified data and strategy applied for such computing.
The code in this module is essentially based on the http://hackage.haskell.org/package/Histogram package by Mike Izbicki, who kindly agreed to re-license his library under BSD3, which allowed me to use his code and comments with some modifications.
Synopsis
- type Histogram = [(Double, [Int])]
- histogram :: BinningStrategy -> [[Double]] -> Histogram
- histogramBinSize :: Double -> [[Double]] -> Histogram
- histogramNumBins :: Int -> [[Double]] -> Histogram
- type BinningStrategy = [Double] -> Int
- binSturges :: BinningStrategy
- binDoane :: BinningStrategy
- binSqrt :: BinningStrategy
- binScott :: BinningStrategy
Creating Histograms
type Histogram = [(Double, [Int])] Source #
Holds all the information needed to plot the histogram
for a list of different series. Each series produces its
own item in the resuling [Int]
list that may contain
zeros.
histogram :: BinningStrategy -> [[Double]] -> Histogram Source #
Creates a histogram by specifying the list of series. Call it with one of
the binning strategies that is appropriate to the type of data you have.
If you don't know, then try using binSturges
.
histogramBinSize :: Double -> [[Double]] -> Histogram Source #
Create a histogram by specifying the exact bin size. You probably don't want to use this function, and should use histogram with an appropriate binning strategy.
histogramNumBins :: Int -> [[Double]] -> Histogram Source #
Create a histogram by the specified approximated number of bins. You probably don't want to use this function, and should use histogram with an appropriate binning strategy.
Binning Strategies
type BinningStrategy = [Double] -> Int Source #
The strategy applied to calculate the histogram bins.
binSturges :: BinningStrategy Source #
Sturges' binning strategy is the least computational work, but recommended for only normal data.
binDoane :: BinningStrategy Source #
Doane's binning strategy extends Sturges' for non-normal data. It takes a little more time because it must calculate the kurtosis (peakkiness) of the distribution.
binSqrt :: BinningStrategy Source #
Using the sqrt of the number of samples is not supported by any theory, but is commonly used by excel and other histogram making software.
binScott :: BinningStrategy Source #
Scott's rule is the optimal solution for normal data, but requires more computation than Sturges'.