Commits

Bryan O'Sullivan committed 96a3b28

Increase the upper bound by epsilon.

This gives us a closed interval instead of a half-open interval, so that we
can correctly bin values at both upper and lower bounds.

This fixes bug #29.

  • Participants
  • Parent commits 053e153

Comments (0)

Files changed (1)

File Statistics/Sample/Histogram.hs

     , range
     ) where
 
+import Numeric.MathFunctions.Constants (m_epsilon)
 import Statistics.Function (minMax)
 import qualified Data.Vector.Generic as G
 import qualified Data.Vector.Generic.Mutable as GM
          GM.write bins b . (+1) =<< GM.read bins b
          go (i+1)
        len = G.length xs
-       d = (hi - lo) / fromIntegral numBins
+       d = ((hi - lo) * (1 + realToFrac m_epsilon)) / fromIntegral numBins
 {-# INLINE histogram_ #-}
 
 -- | /O(n)/ Compute decent defaults for the lower and upper bounds of