haskell / statistics

A fast, high quality library for computing with statistics in Haskell.
http://hackage.haskell.org/package/statistics
BSD 2-Clause "Simplified" License
300 stars 68 forks source link

Typo in binomail distribution #181

Closed vvladislav closed 2 years ago

vvladislav commented 2 years ago

Hello, in Statistics.Distribution.Binomial.hs I found wrong behavior in check that p in [0,1]. I think you want to write:

binomialE n p
  | n < 0            = Nothing
  | p >= 0 && p <= 1 = Just (BD n p)
  | otherwise        = Nothing

Because p >= 0 || p <= 1 is true for any p.

https://github.com/haskell/statistics/blob/c7a3d47eccd09e4f6a230cd27054d8ccb68f34b7/Statistics/Distribution/Binomial.hs#L168

Shimuuar commented 2 years ago

Yes, you're right. Small nitpick expression evaluates to false for NaN. :)

Thank you for the report. 0.16.0.2 with fix is on hackage

vvladislav commented 2 years ago

I was glad to help)