statrs-dev / statrs

Statistical computation library for Rust
https://docs.rs/statrs/latest/statrs/
MIT License
546 stars 78 forks source link

Improve geometric distribution CDF so it handles small p correctly. #157

Closed WarrenWeckesser closed 2 years ago

WarrenWeckesser commented 2 years ago

The subtraction 1 - p in the formula 1 - (1 - p) ^ x loses precision when p is small. The mathematically equivalent expression -expm1(log1p(-p)*x) avoids the loss of precision.

troublescooter commented 2 years ago

Thanks!