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

Add Lognormal and Weibull distributions #165

Closed infinity0 closed 2 years ago

infinity0 commented 4 years ago

Thanks for the quick review! I've changed to using expm1 and log1p as you said, and added some tests.

Since lognormal generates very large values in quantile I had to tweak complQuantileCheck to make it pass, I figured since the relative error was OK it was worth keeping the test enabled, but you should take a look. Likewise I had to set prec_quantile_CDF _ = (64,64), 48 was insufficient, I hope this is OK too.

I also changed lognormalDistrE to forbid too-large values of sigma (in practise, > about 20) because these cause the variance to be > m_huge.

infinity0 commented 4 years ago

I've added another commit that adds constructors for those distributions in terms of the mean and stddev, rather than their formal parameters. Lemme know if you'd rather have them as a separate PR, I figured it was OK here since they're quite small.

The weibull one is not very satisfactory but it was the best one I could find online, and I still don't understand where that -1.086 number comes from, the paper I cite just plucks it out of thin air with no explanation...

infinity0 commented 4 years ago

Thanks! Yes it was good to run them, I missed them at first. Caught a few typos and corner cases. :)

Shimuuar commented 2 years ago

I finally got around to merge this PR. Thanks a lot and sorry for the wait