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

Hypergeometric: Implement accurate complCumulative. #195

Closed lorinder closed 1 year ago

lorinder commented 1 year ago

The implementation of complCumulative was missing, reverting to the default implementation of 1 - cumulative; which results in accuracy loss when cumulative is close to 1.

The new implementation of complCumulative is naive, but in line with the implementation of cumulative.

Also, fix spaces in error message related to wrong parameter selection.

lorinder commented 1 year ago

I forgot to give an example on this one. Here it is:

ghci> pa = complCumulative (hypergeometric 27 53 13) 12
ghci> pa
2.383939585826056e-5

The correct answer in this case is 2.3839395858219576e-5.