All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Added more inverse cumulative distribution functions.
- Introduced feature flags:
rand
andnalgebra
. - Added the
std_dev
method to theDistribution
trait explicitly. - Supported sampling integers from discrete distributions.
- Added support for the Gumbel distribution.
- Migrated multivariate distributions to generic dimensions.
- Replaced
StatsError
with module-level error types indistribution
and its children. - Changed
checked_logit
,checked_multinomial
, and similar methods to returnOption
to handle invalid inputs. - Changed
Chi
distribution to useu64
for degrees of freedom.
- Upgraded
nalgebra
to version 0.33.- Upgrades MSRV to 1.65+
- Improved documentation and added examples (e.g., for Hypergeometric distribution).
- Added MSRV (Minimum Supported Rust Version) metadata to
Cargo.toml
and documentation. - Introduced coverage reporting with
llvm-cov
. - Updated CI to check all feature combinations and ensure MSRV compliance.
- Added an MSRV badge to
crates.io
.
- Corrected formatting issues in documentation.
- Fixed several
rustdoc
warnings. - Expanded test coverage for Dirichlet and Multinomial distributions.
- Improved ergonomics at cli for tests and ensured compatibility with updated NIST data.
- Replaced
StatsError
with module-level error types. - Deprecated the
error
module and preformatted NIST data. - Removed
rustfmt.toml
as part of CI clean-up.
- @SabrinaJewson and @alimf17 made their first contributions!
0.17.1 - 2024-06-08
- Release statrs version 0.17.1 by @YeungOnion
- Code in benches still needs criterion by @YeungOnion
0.17.0 - 2024-05-30
- specializes
inverse_cdf()
for Uniform (#166) - Add way to get standard normal distribution easily. (#228)
- reject constructing Uniform of infinite support (#218)
- extend
StatsError
for finiteness (#218) - default implementation of survival function with generics (#179)
- update
MultivariateNormal
API- construct from nalgebra with
MultivariateNormal::new_from_nalgebra
(#177) - support
std::vec
vector input in addition tonalgebra
vectors (#199)
- construct from nalgebra with
- Update nalgebra to 0.32 (#187)
- for Gamma with shape<1 there is no mode, returns
None
instead of some negative number (#212) - fix precision of ::inverse_cdf with some newton raphson steps (#227)
- adds test case from #200
- fix integer bisection for default implementation of
<D as DiscreteCDF>::inverse_cdf
(#220)- also add tests from (#185)
- Remove "nightly" feature and drop testing requirement for
nightly
(#234) - Allow some imprecision in specific test case (#215)
- Update CI (#215)
- Check formatting in CI via rustfmt
- Expand CI test job
- Add clippy job to CI
- update README with formatting and adding to "Contributing" (#213)
- Add test asserting that
StatsError
is Sync & Send (#226) - Rename private struct NonNAN to NonNan (#222)
- Remove
lazy-static
dependency and make FCACHE a proper const (#211) - crate examples shall be in docstrings instead of README (#213)
- alias
inverse_cdf
as "quantile function" in docs (#213) - docstrings with math shall be
text
instead ofignore
(#213)
- Adds an
sf
method to theContinuousCDF
andDiscreteCDF
traits- Calculates the survival function (CDF complement) for the distribution.
- Survival function implemented for all distributions implementing
ContinuousCDF
andDiscreteCDF
- See PR description for in-depth changes
- update
nalgebra
to0.29
- upgrade
nalgebra
to0.27.1
to avoid RUSTSEC-2021-0070
- upgrade
rand
dependency to0.8
- fix inaccurate sampling of
Gamma
- Implemented Empirical distribution
- Implemented Laplace distribution
- Removed Checked* traits
- Almost clippy-clean
- Almost fully enabled rustfmt
- Begin applying consistent numeric relative-accuracy targets with the approx crate
- Introduce macro to generate testing boilerplate, yet not all tests use this yet
- Moved to dynamic vectors in the MultivariateNormal distribution
- Reduced a number of distribution-specific traits into the Distribution and DiscreteDistribution traits
- Implemented
MultivariateNormal
distribution (depends onnalgebra 0.19
) - Implemented
Dirac
distribution - Implemented
Negative Binomial
distribution
- upgrade
rand
dependency to0.7
- upgrade
rand
dependency to0.6
- Implement
CheckedInverseCDF
andInverseCDF
forNormal
distribution
- upgrade
rand
dependency to0.5
- Removes the
Distribution
trait in favor of therand::distributions::Distribution
trait - Removed functions deprecated in
0.8.0
(periodic
,periodic_custom
,sinusoidal
,sinusoidal_custom
)
- implemented infinite sequence generator for periodic sequence
- implemented infinite sequence generator for sinusoidal sequence
- implemented infinite sequence generator for square sequence
- implemented infinite sequence generator for triangle sequence
- implemented infinite sequence generator for sawtooth sequence
- deprecate old non-infinite iterators in favor of new infinite iterators with
take
- Implemented
Pareto
distribution - Implemented
Entropy
trait for theCategorical
distribution - Add a
checked_
interface to all distribution methods and functions that may panic
cdf(x)
,pdf(x)
andpmf(x)
now return the correct value instead of panicking whenx
is outside the range of values that the distribution can attain.- 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]
. - Implement
generate::log_spaced
function - Implement
generate::Periodic
iterator - Implement
generate::Sinusoidal
iterator - Implement
generate::Square
iterator - Implement
generate::Triangle
iterator - Implement
generate::Sawtooth
iterator - Deprecate
generate::periodic
andgenerate::periodic_custom
- Deprecate
generate::sinusoidal
andgenerate::sinusoidal_custom
Note: A recent commit to the Rust nightly build causes compile errors when using
empty slices with the Statistics
trait, specifically the Statistics::min
and
Statistics::max
methods. This only affects the case where the compiler must infer
the type of the empty slice:
use statrs::statistics::Statistics;
// compile error! Assumes the use of Ord::min rather than
// Statistcs::min
let x = [];
assert!(x.min().is_nan());
The fix is to pin the type of the empty slice:
// no compile error
let x: [f64; 0] = [];
assert!(x.min().is_nan());
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
- Implemented
Categorical
distribution - Implemented
Erlang
distribution - Implemented
Multinomial
distribution - New
InverseCDF
trait for distributions that implement the inverse cdf function
gamma::gamma_ur
,gamma::gamma_ui
,gamma::gamma_lr
, andgamma::gamma_li
now follow strict gamma function domain, panicking ifa
orx
are not in(0, +inf)
beta::beta_reg
no longer allows0.0
fora
orb
argumentsInverseGamma
distribution no longer acceptsf64::INFINITY
as valid arguments forshape
orrate
as the value is nonsenseBinomial::cdf
no longer accepts arguments outside the domain of[0, n]
Bernoulli::cdf
no longer accepts arguments outside the domain of[0, 1]
DiscreteUniform::cdf
no longer accepts arguments outside the domain of[min, max]
Uniform::cdf
no longer accepts arguments outside the domain of[min, max]
Triangular::cdf
no longer accepts arguments outside the domain of[min, max]
FisherSnedecor
no longer acceptsf64::INFINITY
as a valid argument forfreedom_1
orfreedom_2
FisherSnedecor::cdf
no longer accepts arguments outside the domain of[0, +inf)
Geometric::cdf
no longer accepts non-positive argumentsNormal
now uses the Ziggurat method to generate random samples. This also affects all distributions depending onNormal
for sampling includingChi
,LogNormal
,Gamma
, andStudentsT
Exponential
now uses the Ziggurat methd to generate random samples.Binomial
now implementsUnivariate<u64, f64>
rather thanUnivariate<i64, f64>
, meaningBinomial::min
andBinomial::max
now returnu64
Bernoulli
now implementsUnivariate<u64, f64>
rather thanUnivariate<i64, f64>
, meaningBernoulli::min
andBernoulli::min
now returnu64
Geometric
now implementsUnivariate<u64, f64>
rather thanUnivariate<i64, f64>
, meaningGeometric::min
andGeometric::min
now returnu64
Poisson
now implementsUnivariate<u64, f64>
rather thanUnivariate<i64, f64>
, meaningPoisson::min
andPoisson::min
now returnu64
Binomial
now implementsMode<u64>
instead ofMode<i64>
Bernoulli
now implementsMode<u64>
instead ofMode<i64>
Poisson
now implementsMode<u64>
instead ofMode<i64>
Geometric
now implementsMode<u64>
instead ofMode<i64>
Hypergeometric
now implementsMode<u64>
instead ofMode<i64>
Binomial
now implementsDiscrete<u64, f64>
rather thanDiscrete<i64, f64>
Bernoulli
now implementsDiscrete<u64, f64>
rather thanDiscrete<i64, f64>
Geometric
now implementsDiscrete<u64, f64>
rather thanDiscrete<i64, f64>
Hypergeometric
now implementsDiscrete<u64, f64>
rather thanDiscrete<i64, f64>
Poisson
now implementsDiscrete<u64, f64>
rather thanDiscrete<i64, f64>
- Fixed critical bug in
normal::sample_unchecked
where it was returningNaN
- Implemented the
logistic::logistic
special function - Implemented the
logistic::logit
special function - Implemented the
factorial::multinomial
special function - Implemented the
harmonic::harmonic
special function - Implemented the
harmonic::gen_harmonic
special function - Implemented the
InverseGamma
distribution - Implemented the
Geometric
distribution - Implemented the
Hypergeometric
distribution gamma::gamma_ur
now panics whenx > 0
ora == f64::NEG_INFINITY
. In addition, it also returnsf64::NAN
whena == f64::INFINITY
and0.0
whenx == f64::INFINITY
Gamma::pdf
andGamma::ln_pdf
now returnf64::NAN
if any ofshape
,rate
, orx
aref64::INFINITY
Binomial::pdf
andBinomial::ln_pdf
now panic ifx > n
orx < 0
Bernoulli::pdf
andBernoulli::ln_pdf
now panic ifx > 1
orx < 0
- Implemented the
exponential::integral
special function - Implemented the
Cauchy
(otherwise known as theLorenz
) distribution - Implemented the
Dirichlet
distribution Continuous
andDiscrete
traits no longer dependent onDistribution
trait
- Implemented the
FisherSnedecor
(F) distribution
- Removed print statements from
ln_pdf
method inBeta
distribution
- Moved methods
min
andmax
out of traitUnivariate
into their own respective traitsMin
andMax
- Traits
Min
,Max
,Mean
,Variance
,Entropy
,Skewness
,Median
, andMode
moved fromdistribution
module tostatistics
module Mean
,Variance
,Entropy
,Skewness
,Median
, andMode
no longer depend onDistribution
traitMean
,Variance
,Skewness
, andMode
are now generic over only one type, the return type, due to not depending onDistribution
anymoreorder_statistic
,median
,quantile
,percentile
,lower_quartile
,upper_quartile
,interquartile_range
, andranks
methods removed fromStatistics
trait.min
,max
,mean
,variance
, andstd_dev
methods added toStatistics
traitStatistics
trait now implemented for all types implementingIntoIterator
whereItem
implementsBorrow<f64>
. Slice now implicitly implementsStatistics
through this new implementation.- Slice still implements
Min
,Max
,Mean
, andVariance
but now through theStatistics
implementation rather than its own implementation InplaceStatistics
renamed toOrderStatistics
, all methods inInplaceStatistics
have_inplace
trimmed from method name.- Inverse DiGamma function implemented with signature
gamma::inv_digamma(x: f64) -> f64
- Created
statistics
module andStatistics
trait Statistics
trait implementation for[f64]
- Implemented
Beta
distribution - Added
Modulus
trait and implementations forf32
,f64
,i32
,i64
,u32
, andu64
ineuclid
module - Added periodic and sinusoidal vector generation functions in
generate
module