statistics 0.10.5.1 → 0.10.5.2
raw patch · 3 files changed
+18/−3 lines, 3 files
Files
- ChangeLog +7/−0
- Statistics/Sample/Histogram.hs +10/−2
- statistics.cabal +1/−1
ChangeLog view
@@ -1,3 +1,10 @@++Changes in 0.10.5.2++ * histogram correctly chooses range when all elements in the sample are same+ (bug #57)++ Changes in 0.10.5.1 * Bug fix for S.Distributions.Normal.standard introduced in 0.10.5.0 (Bug #56)
Statistics/Sample/Histogram.hs view
@@ -19,7 +19,7 @@ , range ) where -import Numeric.MathFunctions.Constants (m_epsilon)+import Numeric.MathFunctions.Constants (m_epsilon,m_tiny) import Statistics.Function (minMax) import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as GM@@ -84,13 +84,21 @@ -- The upper and lower bounds used are @(lo-d, hi+d)@, where -- -- @d = (maximum sample - minimum sample) / ((bins - 1) * 2)@+--+-- If all elements in the sample are the same and equal to @x@ range+-- is set to @(x - |x|/10, x + |x|/10)@. And if @x@ is equal to 0 range+-- is set to @(-1,1)@. This is needed to avoid creating histogram with+-- zero bin size. range :: (G.Vector v Double) => Int -- ^ Number of bins (must be positive). -> v Double -- ^ Sample data (cannot be empty).- -> (Double, Double)+ -> (Double, Double) range numBins xs | numBins < 1 = error "Statistics.Histogram.range: invalid bin count" | G.null xs = error "Statistics.Histogram.range: empty sample"+ | lo == hi = case abs lo / 10 of+ a | a < m_tiny -> (-1,1)+ | otherwise -> (lo - a, lo + a) | otherwise = (lo-d, hi+d) where d | numBins == 1 = 0
statistics.cabal view
@@ -1,5 +1,5 @@ name: statistics-version: 0.10.5.1+version: 0.10.5.2 synopsis: A library of statistical types, data, and functions description: This library provides a number of common functions and types useful