| 1 |
# Changelog |
| 2 |
|
| 3 |
All notable changes to this project will be documented in this file. |
| 4 |
|
| 5 |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 |
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 |
|
| 8 |
## [0.18.0] - 2024-12-02 |
| 9 |
|
| 10 |
### ✨ Added |
| 11 |
- Added more inverse cumulative distribution functions. |
| 12 |
- Introduced feature flags: `rand` and `nalgebra`. |
| 13 |
- Added the `std_dev` method to the `Distribution` trait explicitly. |
| 14 |
- Supported sampling integers from discrete distributions. |
| 15 |
- Added support for the Gumbel distribution. |
| 16 |
|
| 17 |
### ⚠️ Breaking Changes |
| 18 |
- Migrated multivariate distributions to generic dimensions. |
| 19 |
- Replaced `StatsError` with module-level error types in `distribution` and its children. |
| 20 |
- Changed `checked_logit`, `checked_multinomial`, and similar methods to return `Option` to handle invalid inputs. |
| 21 |
- Changed `Chi` distribution to use `u64` for degrees of freedom. |
| 22 |
|
| 23 |
### 🛠️ Changed |
| 24 |
- Upgraded `nalgebra` to version 0.33. |
| 25 |
- Upgrades MSRV to 1.65+ |
| 26 |
- Improved documentation and added examples (e.g., for Hypergeometric distribution). |
| 27 |
- Added MSRV (Minimum Supported Rust Version) metadata to `Cargo.toml` and documentation. |
| 28 |
- Introduced coverage reporting with `llvm-cov`. |
| 29 |
- Updated CI to check all feature combinations and ensure MSRV compliance. |
| 30 |
- Added an MSRV badge to `crates.io`. |
| 31 |
|
| 32 |
### ✅ Fixed |
| 33 |
- Corrected formatting issues in documentation. |
| 34 |
- Fixed several `rustdoc` warnings. |
| 35 |
- Expanded test coverage for Dirichlet and Multinomial distributions. |
| 36 |
- Improved ergonomics at cli for tests and ensured compatibility with updated NIST data. |
| 37 |
|
| 38 |
### ❌ Removed |
| 39 |
- Replaced `StatsError` with module-level error types. |
| 40 |
- Deprecated the `error` module and preformatted NIST data. |
| 41 |
- Removed `rustfmt.toml` as part of CI clean-up. |
| 42 |
|
| 43 |
### 🎉 New Contributors |
| 44 |
- @SabrinaJewson and @alimf17 made their first contributions! |
| 45 |
|
| 46 |
## [0.17.1] - 2024-06-08 |
| 47 |
### Details |
| 48 |
#### Changed |
| 49 |
- Release statrs version 0.17.1 by @YeungOnion |
| 50 |
|
| 51 |
#### Fixed |
| 52 |
- Code in benches still needs criterion by @YeungOnion |
| 53 |
|
| 54 |
[unreleased]: https://github.com/YeungOnion/statrs/compare/v0.17.1..HEAD |
| 55 |
[0.17.1]: https://github.com/YeungOnion/statrs/compare/v0.17.0..v0.17.1 |
| 56 |
|
| 57 |
<!-- generated by git-cliff --> |
| 58 |
|
| 59 |
## [0.17.0](https://github.com/statrs-dev/statrs/compare/v0.16.0...v0.17.0) - 2024-05-30 |
| 60 |
|
| 61 |
### Added |
| 62 |
- specializes `inverse_cdf()` for Uniform (#166) |
| 63 |
- Add way to get standard normal distribution easily. (#228) |
| 64 |
- reject constructing Uniform of infinite support (#218) |
| 65 |
- extend `StatsError` for finiteness (#218) |
| 66 |
- default implementation of survival function with generics (#179) |
| 67 |
- update `MultivariateNormal` API |
| 68 |
- construct from nalgebra with `MultivariateNormal::new_from_nalgebra` (#177) |
| 69 |
- support `std::vec` vector input in addition to `nalgebra` vectors (#199) |
| 70 |
|
| 71 |
### Fixed |
| 72 |
- Update nalgebra to 0.32 (#187) |
| 73 |
- for Gamma with shape<1 there is no mode, returns `None` instead of some negative number (#212) |
| 74 |
- fix precision of <Gamma as ContinuousCDF>::inverse_cdf with some newton raphson steps (#227) |
| 75 |
- adds test case from #200 |
| 76 |
- fix integer bisection for default implementation of `<D as DiscreteCDF>::inverse_cdf` (#220) |
| 77 |
- also add tests from (#185) |
| 78 |
|
| 79 |
### Other |
| 80 |
- Remove "nightly" feature and drop testing requirement for `nightly` (#234) |
| 81 |
- Allow some imprecision in specific test case (#215) |
| 82 |
- Update CI (#215) |
| 83 |
- Check formatting in CI via rustfmt |
| 84 |
- Expand CI test job |
| 85 |
- Add clippy job to CI |
| 86 |
- update README with formatting and adding to "Contributing" (#213) |
| 87 |
- Add test asserting that `StatsError` is Sync & Send (#226) |
| 88 |
- Rename private struct NonNAN<T> to NonNan<T> (#222) |
| 89 |
- Remove `lazy-static` dependency and make FCACHE a proper const (#211) |
| 90 |
- crate examples shall be in docstrings instead of README (#213) |
| 91 |
- alias `inverse_cdf` as "quantile function" in docs (#213) |
| 92 |
- docstrings with math shall be `text` instead of `ignore` (#213) |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
## [0.16.0] |
| 97 |
|
| 98 |
- Adds an `sf` method to the `ContinuousCDF` and `DiscreteCDF` traits |
| 99 |
- Calculates the survival function (CDF complement) for the distribution. |
| 100 |
- Survival function implemented for all distributions implementing `ContinuousCDF` and `DiscreteCDF` |
| 101 |
- See [PR description](https://github.com/statrs-dev/statrs/pull/172) for in-depth changes |
| 102 |
- update `nalgebra` to `0.29` |
| 103 |
|
| 104 |
## [v0.15.0](https://www.github.com/statrs-dev/statrs/compare/v0.15.0...v0.16.0) |
| 105 |
|
| 106 |
- upgrade `nalgebra` to `0.27.1` to avoid RUSTSEC-2021-0070 |
| 107 |
|
| 108 |
## [v0.14.0](https://www.github.com/statrs-dev/statrs/compare/v0.14.0...v0.15.0) |
| 109 |
|
| 110 |
- upgrade `rand` dependency to `0.8` |
| 111 |
- fix inaccurate sampling of `Gamma` |
| 112 |
- Implemented Empirical distribution |
| 113 |
- Implemented Laplace distribution |
| 114 |
- Removed Checked\* traits |
| 115 |
- Almost clippy-clean |
| 116 |
- Almost fully enabled rustfmt |
| 117 |
- Begin applying consistent numeric relative-accuracy targets with the approx crate |
| 118 |
- Introduce macro to generate testing boilerplate, yet not all tests use this yet |
| 119 |
- Moved to dynamic vectors in the MultivariateNormal distribution |
| 120 |
- Reduced a number of distribution-specific traits into the Distribution and DiscreteDistribution traits |
| 121 |
|
| 122 |
## [v0.13.0](https://www.github.com/statrs-dev/statrs/compare/v0.12.0...v0.13.0) |
| 123 |
|
| 124 |
- Implemented `MultivariateNormal` distribution (depends on `nalgebra 0.19`) |
| 125 |
- Implemented `Dirac` distribution |
| 126 |
- Implemented `Negative Binomial` distribution |
| 127 |
|
| 128 |
## [v0.12.0](https://www.github.com/statrs-dev/statrs/compare/v0.11.0...v0.12.0) |
| 129 |
|
| 130 |
- upgrade `rand` dependency to `0.7` |
| 131 |
|
| 132 |
## [v0.11.0](https://www.github.com/statrs-dev/statrs/compare/v0.10.0...v0.11.0) |
| 133 |
|
| 134 |
- upgrade `rand` dependency to `0.6` |
| 135 |
- Implement `CheckedInverseCDF` and `InverseCDF` for `Normal` distribution |
| 136 |
|
| 137 |
## [v0.10.0](https://www.github.com/statrs-dev/statrs/compare/v0.9.0...v0.10.0) |
| 138 |
|
| 139 |
- upgrade `rand` dependency to `0.5` |
| 140 |
- Removes the `Distribution` trait in favor of the `rand::distributions::Distribution` trait |
| 141 |
- Removed functions deprecated in `0.8.0` (`periodic`, `periodic_custom`, `sinusoidal`, `sinusoidal_custom`) |
| 142 |
|
| 143 |
## [v0.9.0](https://www.github.com/statrs-dev/statrs/compare/v0.8.0...v0.9.0) |
| 144 |
|
| 145 |
- implemented infinite sequence generator for periodic sequence |
| 146 |
- implemented infinite sequence generator for sinusoidal sequence |
| 147 |
- implemented infinite sequence generator for square sequence |
| 148 |
- implemented infinite sequence generator for triangle sequence |
| 149 |
- implemented infinite sequence generator for sawtooth sequence |
| 150 |
- deprecate old non-infinite iterators in favor of new infinite iterators with `take` |
| 151 |
- Implemented `Pareto` distribution |
| 152 |
- Implemented `Entropy` trait for the `Categorical` distribution |
| 153 |
- Add a `checked_` interface to all distribution methods and functions that may panic |
| 154 |
|
| 155 |
## [v0.8.0](https://www.github.com/statrs-dev/statrs/compare/v0.7.0...v0.8.0) |
| 156 |
|
| 157 |
- `cdf(x)`, `pdf(x)` and `pmf(x)` now return the correct value instead of panicking when `x` is outside the range of values that the distribution can attain. |
| 158 |
- Fixed a bug in the `Uniform` distribution implementation where samples were drawn from range `[min, max + 1)` instead of `[min, max]`. The samples are now drawn correctly from the range `[min, max]`. |
| 159 |
- Implement `generate::log_spaced` function |
| 160 |
- Implement `generate::Periodic` iterator |
| 161 |
- Implement `generate::Sinusoidal` iterator |
| 162 |
- Implement `generate::Square` iterator |
| 163 |
- Implement `generate::Triangle` iterator |
| 164 |
- Implement `generate::Sawtooth` iterator |
| 165 |
- Deprecate `generate::periodic` and `generate::periodic_custom` |
| 166 |
- Deprecate `generate::sinusoidal` and `generate::sinusoidal_custom` |
| 167 |
|
| 168 |
Note: A recent commit to the Rust nightly build causes compile errors when using |
| 169 |
empty slices with the `Statistics` trait, specifically the `Statistics::min` and |
| 170 |
`Statistics::max` methods. This only affects the case where the compiler must infer |
| 171 |
the type of the empty slice: |
| 172 |
|
| 173 |
``` |
| 174 |
use statrs::statistics::Statistics; |
| 175 |
|
| 176 |
// compile error! Assumes the use of Ord::min rather than |
| 177 |
// Statistcs::min |
| 178 |
let x = []; |
| 179 |
assert!(x.min().is_nan()); |
| 180 |
``` |
| 181 |
|
| 182 |
The fix is to pin the type of the empty slice: |
| 183 |
|
| 184 |
``` |
| 185 |
// no compile error |
| 186 |
let x: [f64; 0] = []; |
| 187 |
assert!(x.min().is_nan()); |
| 188 |
``` |
| 189 |
|
| 190 |
Since the regression affects a very slim edge-case and the fix is very simple, no breaking changes to the `Statistics` API was deemed necessary |
| 191 |
|
| 192 |
## [v0.7.0](https://www.github.com/statrs-dev/statrs/compare/v0.6.0...v0.7.0) |
| 193 |
|
| 194 |
- Implemented `Categorical` distribution |
| 195 |
- Implemented `Erlang` distribution |
| 196 |
- Implemented `Multinomial` distribution |
| 197 |
- New `InverseCDF` trait for distributions that implement the inverse cdf function |
| 198 |
|
| 199 |
## [v0.6.0](https://www.github.com/statrs-dev/statrs/compare/v0.5.1...v0.6.0) |
| 200 |
|
| 201 |
- `gamma::gamma_ur`, `gamma::gamma_ui`, `gamma::gamma_lr`, and `gamma::gamma_li` now follow strict gamma function domain, panicking if `a` or `x` are not in `(0, +inf)` |
| 202 |
- `beta::beta_reg` no longer allows `0.0` for `a` or `b` arguments |
| 203 |
- `InverseGamma` distribution no longer accepts `f64::INFINITY` as valid arguments for `shape` or `rate` as the value is nonsense |
| 204 |
- `Binomial::cdf` no longer accepts arguments outside the domain of `[0, n]` |
| 205 |
- `Bernoulli::cdf` no longer accepts arguments outside the domain of `[0, 1]` |
| 206 |
- `DiscreteUniform::cdf` no longer accepts arguments outside the domain of `[min, max]` |
| 207 |
- `Uniform::cdf` no longer accepts arguments outside the domain of `[min, max]` |
| 208 |
- `Triangular::cdf` no longer accepts arguments outside the domain of `[min, max]` |
| 209 |
- `FisherSnedecor` no longer accepts `f64::INFINITY` as a valid argument for `freedom_1` or `freedom_2` |
| 210 |
- `FisherSnedecor::cdf` no longer accepts arguments outside the domain of `[0, +inf)` |
| 211 |
- `Geometric::cdf` no longer accepts non-positive arguments |
| 212 |
- `Normal` now uses the Ziggurat method to generate random samples. This also affects all distributions depending on `Normal` for sampling |
| 213 |
including `Chi`, `LogNormal`, `Gamma`, and `StudentsT` |
| 214 |
- `Exponential` now uses the Ziggurat methd to generate random samples. |
| 215 |
- `Binomial` now implements `Univariate<u64, f64>` rather than `Univariate<i64, f64>`, meaning `Binomial::min` and `Binomial::max` now return `u64` |
| 216 |
- `Bernoulli` now implements `Univariate<u64, f64>` rather than `Univariate<i64, f64>`, meaning `Bernoulli::min` and `Bernoulli::min` now return `u64` |
| 217 |
- `Geometric` now implements `Univariate<u64, f64>` rather than `Univariate<i64, f64>`, meaning `Geometric::min` and `Geometric::min` now return `u64` |
| 218 |
- `Poisson` now implements `Univariate<u64, f64>` rather than `Univariate<i64, f64>`, meaning `Poisson::min` and `Poisson::min` now return `u64` |
| 219 |
- `Binomial` now implements `Mode<u64>` instead of `Mode<i64>` |
| 220 |
- `Bernoulli` now implements `Mode<u64>` instead of `Mode<i64>` |
| 221 |
- `Poisson` now implements `Mode<u64>` instead of `Mode<i64>` |
| 222 |
- `Geometric` now implements `Mode<u64>` instead of `Mode<i64>` |
| 223 |
- `Hypergeometric` now implements `Mode<u64>` instead of `Mode<i64>` |
| 224 |
- `Binomial` now implements `Discrete<u64, f64>` rather than `Discrete<i64, f64>` |
| 225 |
- `Bernoulli` now implements `Discrete<u64, f64>` rather than `Discrete<i64, f64>` |
| 226 |
- `Geometric` now implements `Discrete<u64, f64>` rather than `Discrete<i64, f64>` |
| 227 |
- `Hypergeometric` now implements `Discrete<u64, f64>` rather than `Discrete<i64, f64>` |
| 228 |
- `Poisson` now implements `Discrete<u64, f64>` rather than `Discrete<i64, f64>` |
| 229 |
|
| 230 |
## [v0.5.1](https://www.github.com/statrs-dev/statrs/compare/v0.5.0...v0.5.1) |
| 231 |
|
| 232 |
- Fixed critical bug in `normal::sample_unchecked` where it was returning `NaN` |
| 233 |
|
| 234 |
## [v0.5.0](https://www.github.com/statrs-dev/statrs/compare/v0.4.0...v0.5.0) |
| 235 |
|
| 236 |
- Implemented the `logistic::logistic` special function |
| 237 |
- Implemented the `logistic::logit` special function |
| 238 |
- Implemented the `factorial::multinomial` special function |
| 239 |
- Implemented the `harmonic::harmonic` special function |
| 240 |
- Implemented the `harmonic::gen_harmonic` special function |
| 241 |
- Implemented the `InverseGamma` distribution |
| 242 |
- Implemented the `Geometric` distribution |
| 243 |
- Implemented the `Hypergeometric` distribution |
| 244 |
- `gamma::gamma_ur` now panics when `x > 0` or `a == f64::NEG_INFINITY`. In addition, it also returns `f64::NAN` when `a == f64::INFINITY` and `0.0` when `x == f64::INFINITY` |
| 245 |
- `Gamma::pdf` and `Gamma::ln_pdf` now return `f64::NAN` if any of `shape`, `rate`, or `x` are `f64::INFINITY` |
| 246 |
- `Binomial::pdf` and `Binomial::ln_pdf` now panic if `x > n` or `x < 0` |
| 247 |
- `Bernoulli::pdf` and `Bernoulli::ln_pdf` now panic if `x > 1` or `x < 0` |
| 248 |
|
| 249 |
## [v0.4.0] |
| 250 |
|
| 251 |
- Implemented the `exponential::integral` special function |
| 252 |
- Implemented the `Cauchy` (otherwise known as the `Lorenz`) distribution |
| 253 |
- Implemented the `Dirichlet` distribution |
| 254 |
- `Continuous` and `Discrete` traits no longer dependent on `Distribution` trait |
| 255 |
|
| 256 |
## [v0.3.2] |
| 257 |
|
| 258 |
- Implemented the `FisherSnedecor` (F) distribution |
| 259 |
|
| 260 |
## [v0.3.1] |
| 261 |
|
| 262 |
- Removed print statements from `ln_pdf` method in `Beta` distribution |
| 263 |
|
| 264 |
## [v0.3.0] |
| 265 |
|
| 266 |
- Moved methods `min` and `max` out of trait `Univariate` into their own respective traits `Min` and `Max` |
| 267 |
- Traits `Min`, `Max`, `Mean`, `Variance`, `Entropy`, `Skewness`, `Median`, and `Mode` moved from `distribution` module to `statistics` module |
| 268 |
- `Mean`, `Variance`, `Entropy`, `Skewness`, `Median`, and `Mode` no longer depend on `Distribution` trait |
| 269 |
- `Mean`, `Variance`, `Skewness`, and `Mode` are now generic over only one type, the return type, due to not depending on `Distribution` anymore |
| 270 |
- `order_statistic`, `median`, `quantile`, `percentile`, `lower_quartile`, `upper_quartile`, `interquartile_range`, and `ranks` methods removed |
| 271 |
from `Statistics` trait. |
| 272 |
- `min`, `max`, `mean`, `variance`, and `std_dev` methods added to `Statistics` trait |
| 273 |
- `Statistics` trait now implemented for all types implementing `IntoIterator` where `Item` implements `Borrow<f64>`. Slice now implicitly implements |
| 274 |
`Statistics` through this new implementation. |
| 275 |
- Slice still implements `Min`, `Max`, `Mean`, and `Variance` but now through the `Statistics` implementation rather than its own implementation |
| 276 |
- `InplaceStatistics` renamed to `OrderStatistics`, all methods in `InplaceStatistics` have `_inplace` trimmed from method name. |
| 277 |
- Inverse DiGamma function implemented with signature `gamma::inv_digamma(x: f64) -> f64` |
| 278 |
|
| 279 |
## [v0.2.0] |
| 280 |
|
| 281 |
- Created `statistics` module and `Statistics` trait |
| 282 |
- `Statistics` trait implementation for `[f64]` |
| 283 |
- Implemented `Beta` distribution |
| 284 |
- Added `Modulus` trait and implementations for `f32`, `f64`, `i32`, `i64`, `u32`, and `u64` in `euclid` module |
| 285 |
- Added periodic and sinusoidal vector generation functions in `generate` module |