clbustos / distribution

Statistical Distributions multi library wrapper. Uses Ruby by default and C (statistics2/GSL) or Java extensions where available.
Other
141 stars 52 forks source link

Fix beta distribution quantiles #26

Closed dmitrykorolev-stripe closed 5 years ago

dmitrykorolev-stripe commented 5 years ago

This fixes ruby implementation of p_value and quantile for beta distribution which are broken for high values of a and b.

For example quantile(0.86, 1076, 1) returns 0.5 while it should return a number close to 1, quantile(0.3, 10_000, 10_000) returns 0.25 while expected result is ~0.5.

tremblay-stripe commented 5 years ago

For values of a which are somewhat larger than b, the CDF will return a true zero and not something like 1.23e-17. This will abort the computation, returning the current guess, which is very far off the expected value.

Thanks @dmitrykorolev-stripe for fixing this!

dmitrykorolev-stripe commented 5 years ago

ptal @clbustos