statrs
Statistical computing library for Rust
0.19.1
35M downloads/mo
#1523 most downloaded on crates.io
statrs-dev/statrs
What this package is like to depend on
Last release 12 days ago
11 Aug 2026
Ships fairly regularly
a new release about every 9 months
Most releases are documented
notes for 18 of 25 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
25 releases · first in 2016
2 releases in the last 12 months
see the full history below
Release timeline
25 releases · Aug 2016 to Aug 2026Releases
latest 25-
0.19.111 Aug 2026Release notes
Open source →Added
- let callers choose the binomial sampling algorithm
Fixed
- Correct exact distribution boundaries
- Beta::sf returning exactly 1.0 for tiny x
- order the selection fast paths by total_cmp, not <=
- replace hand-rolled quickselect with select_nth_unstable_by
- address review on the BINV/BTPE sampler
Other
- Alias f64 constants
- Fix nightly f64 deprecation warnings
- add a selection benchmark, and ordered fast paths it exposed
- build the NaN order-statistic test under no_std
- move binomial sampling into its own module
- split the sampler's branch selection out of the RNG path
- require std for the BTPE chi-square test
- sample Binomial via BINV/BTPE instead of n Bernoulli trials
- Bound the Newton iteration count and cover the quantile guards
- Add safeguarded-Newton inverse_cdf for Chi and InverseGamma
Release notes
Open source →Added
- let callers choose the binomial sampling algorithm
Fixed
- Correct exact distribution boundaries
- Beta::sf returning exactly 1.0 for tiny x
- order the selection fast paths by total_cmp, not <=
- replace hand-rolled quickselect with select_nth_unstable_by
- address review on the BINV/BTPE sampler
Other
- Alias f64 constants
- Fix nightly f64 deprecation warnings
- add a selection benchmark, and ordered fast paths it exposed
- build the NaN order-statistic test under no_std
- move binomial sampling into its own module
- split the sampler's branch selection out of the RNG path
- require std for the BTPE chi-square test
- sample Binomial via BINV/BTPE instead of n Bernoulli trials
- Bound the Newton iteration count and cover the quantile guards
- Add safeguarded-Newton inverse_cdf for Chi and InverseGamma
-
0.19.020 Jul 2026Release notes
Open source →Added
- Add initial no_std support
- gate density estimation behind a "kde" feature
- add first implementation of kernel density estimation.
- add bandwith support for knn density estimation.
- add a more generic implementation of knn density estimation.
- add knn density estimation with kdtree rs tree.
- add OnlineMoments accumulator using Welford
- Add WebAssembly RNG support and update nalgebra
- (distribution) narrow error type to avoid trait object
- (distribution) add non-panicking try_inverse_cdf
- autofix.ci for lint and fmt
- (geometric) finer panic bounds
- (function) add comprehensive kernel suite for KDE and smoothing (#193)
- update to 2024 edition, apply formatting and fix new clippy lints
- [breaking] rely on prec module for precision needs and consts for math constants
- use crate::prec macro assertions in tests instead of
approxdirectly - (prec) write macros that delegate to approx using our defaults
- add
stdfeature - rename
cov_chol_decomptoclone_cov_chol_decompand return a cloned matrix - add methods for covariance decomposition, mean, covariance, and precision in MultivariateNormal
- add accessor methods to various distribution
- (stats_tests) implement KS test
- enhance Levy distribution with comprehensive documentation and methods
- add Levy distribution
- (stats_tests) implement chisquare
- (stats_tests) implement skewtest
- (stats_tests) implement mannwhitneyu
- (stats_tests) implement ttest_onesample
- (stats_tests) implement f_oneway
Fixed
- format assertion message with precision
- fail autofix when clippy --fix can't clear every lint
- drop PAT from autofix-ci.yml
- make autofix clippy match other parts of ci
- Automate MSRV lockfile updates
- update to rand 0.10 and use seeded rng for tests
- fix imports and add some tests.
- kernel density computation.
- drop excess precision requirements
- wrap online stats with iter_statistics for #376
- Refresh MSRV lockfile
- Leave getrandom backend selection to applications
- Use valid order statistics benchmark inputs
- correct entropy formulas for Pareto, Geometric, StudentsT, and Dirichlet
- safeguard Gamma::inverse_cdf Newton step for shape < 1
- compute Multinomial pmf/ln_pmf in log space to avoid NaN for large n
- post updates to rand
- update usage after rand dep update
- restore missing normalization of Dirichlet samples
- unblock PR 364 CI
- remove unused testing imports
- use core instead of std in KDE
- (fmt) apply 2024 formatting to KDE
- (clippy) use constants provided by core
- (clippy) fix clippy failures in CI
- (distribution_tests) pass if only one numerical relationship between pdf and cdf numerically close
- change tests to rely on relative precision for math lib independence
- Gate some stats_tests behind
stdfeature - Use core over std where possible
- update examples in
muandcovmethods to use correct types from nalgebra - exact implementation of Bernoulli cdf
- one more condition in inverse_cdf to account for small enough probabilities.
- feature gate exact KS test one-sample method
Other
- add some geometric pathological tests
- enable autofix to use same clippy as other ci
- Verify df one density integral
- Cover chi-squared boundary behavior
- update lock MSRV for kde deps change
- module docs and feature doc
- add paper reference and simple usage docs
- document DensityError variants and mark non_exhaustive
- add use of one dimensional gaussian kernel function.
- density functions borrowing evaluation pointS instead of owning them.
- some refactoring.
- add performance bench.
- add performance bench.
- [autofix.ci] apply automated fixes
- sample Multinomial via sequential conditional Binomial instead of categorical-style draw-and-scan
- add characterization tests for Multinomial::sample before algorithm change
- share binary-search lookup between Categorical::sample and inverse_cdf
- derive Categorical::sf from cdf instead of storing it
- Categorical now stores normalized values
- Update dependencies and GitHub Actions
- Converge the default continuous inverse_cdf
- Align autofix toolchain with MSRV
- Cover geometric inverse CDF overflow guards
- how to release
- wire up release-plz for crates.io publishing
- remove fast-fail semantics of test ci
- update branch refs from master to main
- Add test for Dirichlet sample normalization
- Add clippy fixes
- more clippy lints
- update lockfile after updating rand
- Format with cargo fmt
- update rand
0.9->0.10 - Fixed redundant word "may"
- use core panic instead of std
- add comments
- add tests for coverage
- add specialised inverse cdf implementation for geometric distribution
- Simplify polynomial evaluation function
- Add a MultivariateNormal constructor from the Cholesky decomposition
- Make documented value of DEFAULT_RELATIVE_ACC match actual value.
- don't fail fast when testing on different OSs
- Bumped MSRV to 1.87.0.
- Bumped
randto 0.9.0 and mechanically modified the code to accommodate the changes in that dependency. - Use -x instead of -1.0 * x
- Merge pull request #336 from FreezyLemon/optimize-chisquare-test
- Fix merge from master
- Merge branch 'master' into optimize-chisquare-test
- lint
- use functionality from prec module outside tests
- doctests should use approx instead of statrs::prec
- update precision docs
- update to not use macro_use directives
- update readme to regard precision, open to updates
- [breaking] define precision consts within mod prec
- add "std" feature-gate where needed
- Remove
catch_unwindfrom test code - add no_std testing
- only implement Error with feature "std"
- use panic! with msg instead of println!
- some tests do not need Vec
- prefer
coreimports overstd - more tests for inverse cdf of discrete distributions.
- more efficient calculation for KS one-sample exact
- remove ks_twosample usage of nalgebra
- cfg wrap for rand
- Fix gamma parameterization for negative binomial sampling
- (deps) bump codecov/codecov-action from 4 to 5
- update docs and result chaining idioms
- enhance checks for continuous distributions with panic safety
- improve numerical stability in CDF derivative check
- add check for derivative of CDF to ensure it matches PDF
- (stats_test) better attribution of sources
- more coverage for
f_oneway - more coverage for
mannwhitneyu mutin function header instead of in function
Release notes
Open source →Added
- Add initial no_std support
- gate density estimation behind a "kde" feature
- add first implementation of kernel density estimation.
- add bandwith support for knn density estimation.
- add a more generic implementation of knn density estimation.
- add knn density estimation with kdtree rs tree.
- add OnlineMoments accumulator using Welford
- Add WebAssembly RNG support and update nalgebra
- (distribution) narrow error type to avoid trait object
- (distribution) add non-panicking try_inverse_cdf
- autofix.ci for lint and fmt
- (geometric) finer panic bounds
- (function) add comprehensive kernel suite for KDE and smoothing (#193)
- update to 2024 edition, apply formatting and fix new clippy lints
- [breaking] rely on prec module for precision needs and consts for math constants
- use crate::prec macro assertions in tests instead of
approxdirectly - (prec) write macros that delegate to approx using our defaults
- add
stdfeature - rename
cov_chol_decomptoclone_cov_chol_decompand return a cloned matrix - add methods for covariance decomposition, mean, covariance, and precision in MultivariateNormal
- add accessor methods to various distribution
- (stats_tests) implement KS test
- enhance Levy distribution with comprehensive documentation and methods
- add Levy distribution
- (stats_tests) implement chisquare
- (stats_tests) implement skewtest
- (stats_tests) implement mannwhitneyu
- (stats_tests) implement ttest_onesample
- (stats_tests) implement f_oneway
Fixed
- format assertion message with precision
- fail autofix when clippy --fix can't clear every lint
- drop PAT from autofix-ci.yml
- make autofix clippy match other parts of ci
- Automate MSRV lockfile updates
- update to rand 0.10 and use seeded rng for tests
- fix imports and add some tests.
- kernel density computation.
- drop excess precision requirements
- wrap online stats with iter_statistics for #376
- Refresh MSRV lockfile
- Leave getrandom backend selection to applications
- Use valid order statistics benchmark inputs
- correct entropy formulas for Pareto, Geometric, StudentsT, and Dirichlet
- safeguard Gamma::inverse_cdf Newton step for shape < 1
- compute Multinomial pmf/ln_pmf in log space to avoid NaN for large n
- post updates to rand
- update usage after rand dep update
- restore missing normalization of Dirichlet samples
- unblock PR 364 CI
- remove unused testing imports
- use core instead of std in KDE
- (fmt) apply 2024 formatting to KDE
- (clippy) use constants provided by core
- (clippy) fix clippy failures in CI
- (distribution_tests) pass if only one numerical relationship between pdf and cdf numerically close
- change tests to rely on relative precision for math lib independence
- Gate some stats_tests behind
stdfeature - Use core over std where possible
- update examples in
muandcovmethods to use correct types from nalgebra - exact implementation of Bernoulli cdf
- one more condition in inverse_cdf to account for small enough probabilities.
- feature gate exact KS test one-sample method
Other
- add some geometric pathological tests
- enable autofix to use same clippy as other ci
- Verify df one density integral
- Cover chi-squared boundary behavior
- update lock MSRV for kde deps change
- module docs and feature doc
- add paper reference and simple usage docs
- document DensityError variants and mark non_exhaustive
- add use of one dimensional gaussian kernel function.
- density functions borrowing evaluation pointS instead of owning them.
- some refactoring.
- add performance bench.
- add performance bench.
- [autofix.ci] apply automated fixes
- sample Multinomial via sequential conditional Binomial instead of categorical-style draw-and-scan
- add characterization tests for Multinomial::sample before algorithm change
- share binary-search lookup between Categorical::sample and inverse_cdf
- derive Categorical::sf from cdf instead of storing it
- Categorical now stores normalized values
- Update dependencies and GitHub Actions
- Converge the default continuous inverse_cdf
- Align autofix toolchain with MSRV
- Cover geometric inverse CDF overflow guards
- how to release
- wire up release-plz for crates.io publishing
- remove fast-fail semantics of test ci
- update branch refs from master to main
- Add test for Dirichlet sample normalization
- Add clippy fixes
- more clippy lints
- update lockfile after updating rand
- Format with cargo fmt
- update rand
0.9->0.10 - Fixed redundant word "may"
- use core panic instead of std
- add comments
- add tests for coverage
- add specialised inverse cdf implementation for geometric distribution
- Simplify polynomial evaluation function
- Add a MultivariateNormal constructor from the Cholesky decomposition
- Make documented value of DEFAULT_RELATIVE_ACC match actual value.
- don't fail fast when testing on different OSs
- Bumped MSRV to 1.87.0.
- Bumped
randto 0.9.0 and mechanically modified the code to accommodate the changes in that dependency. - Use -x instead of -1.0 * x
- Merge pull request #336 from FreezyLemon/optimize-chisquare-test
- Fix merge from master
- Merge branch 'master' into optimize-chisquare-test
- lint
- use functionality from prec module outside tests
- doctests should use approx instead of statrs::prec
- update precision docs
- update to not use macro_use directives
- update readme to regard precision, open to updates
- [breaking] define precision consts within mod prec
- add "std" feature-gate where needed
- Remove
catch_unwindfrom test code - add no_std testing
- only implement Error with feature "std"
- use panic! with msg instead of println!
- some tests do not need Vec
- prefer
coreimports overstd - more tests for inverse cdf of discrete distributions.
- more efficient calculation for KS one-sample exact
- remove ks_twosample usage of nalgebra
- cfg wrap for rand
- Fix gamma parameterization for negative binomial sampling
- (deps) bump codecov/codecov-action from 4 to 5
- update docs and result chaining idioms
- enhance checks for continuous distributions with panic safety
- improve numerical stability in CDF derivative check
- add check for derivative of CDF to ensure it matches PDF
- (stats_test) better attribution of sources
- more coverage for
f_oneway - more coverage for
mannwhitneyu mutin function header instead of in function
-
0.18.003 Dec 2024Release notes
Open source →✨ Added
- Added more inverse cumulative distribution functions.
- Introduced feature flags:
randandnalgebra. - Added the
std_devmethod to theDistributiontrait explicitly. - Supported sampling integers from discrete distributions.
- Added support for the Gumbel distribution.
⚠️ Breaking Changes
- Migrated multivariate distributions to generic dimensions.
- Replaced
StatsErrorwith module-level error types indistributionand its children. - Changed
checked_logit,checked_multinomial, and similar methods to returnOptionto handle invalid inputs. - Changed
Chidistribution to useu64for degrees of freedom.
🛠️ Changed
- Upgraded
nalgebrato 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.tomland 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.
✅ Fixed
- Corrected formatting issues in documentation.
- Fixed several
rustdocwarnings. - Expanded test coverage for Dirichlet and Multinomial distributions.
- Improved ergonomics at cli for tests and ensured compatibility with updated NIST data.
❌ Removed
- Replaced
StatsErrorwith module-level error types. - Deprecated the
errormodule and preformatted NIST data. - Removed
rustfmt.tomlas part of CI clean-up.
🎉 New Contributors
- @SabrinaJewson and @alimf17 made their first contributions!
-
0.17.108 Jun 2024Release notes
Open source →Revival!
A few fixes, some dependency updates, most notably
nalgebra.
Breaking changes in statrs::StatsError, expect more changes later.Release notes
Open source →Details
Changed
- Release statrs version 0.17.1 by @YeungOnion
Fixed
- Code in benches still needs criterion by @YeungOnion
<!-- generated by git-cliff -->
-
0.17.008 Jun 2024Release notes
Open source →Added
- specializes
inverse_cdf()for Uniform (#166) - Add way to get standard normal distribution easily. (#228)
- reject constructing Uniform of infinite support (#218)
- extend
StatsErrorfor finiteness (#218) - default implementation of survival function with generics (#179)
- update
MultivariateNormalAPI- construct from nalgebra with
MultivariateNormal::new_from_nalgebra(#177) - support
std::vecvector input in addition tonalgebravectors (#199)
- construct from nalgebra with
Fixed
- Update nalgebra to 0.32 (#187)
- for Gamma with shape<1 there is no mode, returns
Noneinstead of some negative number (#212) - fix precision of <Gamma as ContinuousCDF>::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)
Other
- 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
StatsErroris Sync & Send (#226) - Rename private struct NonNAN<T> to NonNan<T> (#222)
- Remove
lazy-staticdependency and make FCACHE a proper const (#211) - crate examples shall be in docstrings instead of README (#213)
- alias
inverse_cdfas "quantile function" in docs (#213) - docstrings with math shall be
textinstead ofignore(#213)
- specializes
-
0.16.102 Jun 2024 -
0.16.029 Aug 2022Nothing published for this version
-
0.15.030 Jun 2021 -
0.14.016 May 2021Release notes
Open source →- upgrade
randdependency 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
- upgrade
-
0.13.006 Jul 2020Release notes
Open source →- Implemented
MultivariateNormaldistribution (depends onnalgebra 0.19) - Implemented
Diracdistribution - Implemented
Negative Binomialdistribution
- Implemented
-
0.12.007 Oct 2019 -
0.11.008 May 2019Release notes
Open source →- upgrade
randdependency to0.6 - Implement
CheckedInverseCDFandInverseCDFforNormaldistribution
- upgrade
-
0.10.002 Oct 2018Release notes
Open source →- upgrade
randdependency to0.5 - Removes the
Distributiontrait in favor of therand::distributions::Distributiontrait - Removed functions deprecated in
0.8.0(periodic,periodic_custom,sinusoidal,sinusoidal_custom)
- upgrade
-
0.9.009 Nov 2017Release notes
Open source →- 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
Paretodistribution - Implemented
Entropytrait for theCategoricaldistribution - Add a
checked_interface to all distribution methods and functions that may panic
-
0.8.006 Aug 2017Release notes
Open source →cdf(x),pdf(x)andpmf(x)now return the correct value instead of panicking whenxis outside the range of values that the distribution can attain.- Fixed a bug in the
Uniformdistribution 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_spacedfunction - Implement
generate::Periodiciterator - Implement
generate::Sinusoidaliterator - Implement
generate::Squareiterator - Implement
generate::Triangleiterator - Implement
generate::Sawtoothiterator - Deprecate
generate::periodicandgenerate::periodic_custom - Deprecate
generate::sinusoidalandgenerate::sinusoidal_custom
Note: A recent commit to the Rust nightly build causes compile errors when using empty slices with the
Statisticstrait, specifically theStatistics::minandStatistics::maxmethods. 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
StatisticsAPI was deemed necessary -
0.7.029 May 2017Release notes
Open source →- Implemented
Categoricaldistribution - Implemented
Erlangdistribution - Implemented
Multinomialdistribution - New
InverseCDFtrait for distributions that implement the inverse cdf function
- Implemented
-
0.6.023 Mar 2017Release notes
Open source →gamma::gamma_ur,gamma::gamma_ui,gamma::gamma_lr, andgamma::gamma_linow follow strict gamma function domain, panicking ifaorxare not in(0, +inf)beta::beta_regno longer allows0.0foraorbargumentsInverseGammadistribution no longer acceptsf64::INFINITYas valid arguments forshapeorrateas the value is nonsenseBinomial::cdfno longer accepts arguments outside the domain of[0, n]Bernoulli::cdfno longer accepts arguments outside the domain of[0, 1]DiscreteUniform::cdfno longer accepts arguments outside the domain of[min, max]Uniform::cdfno longer accepts arguments outside the domain of[min, max]Triangular::cdfno longer accepts arguments outside the domain of[min, max]FisherSnedecorno longer acceptsf64::INFINITYas a valid argument forfreedom_1orfreedom_2FisherSnedecor::cdfno longer accepts arguments outside the domain of[0, +inf)Geometric::cdfno longer accepts non-positive argumentsNormalnow uses the Ziggurat method to generate random samples. This also affects all distributions depending onNormalfor sampling includingChi,LogNormal,Gamma, andStudentsTExponentialnow uses the Ziggurat methd to generate random samples.Binomialnow implementsUnivariate<u64, f64>rather thanUnivariate<i64, f64>, meaningBinomial::minandBinomial::maxnow returnu64Bernoullinow implementsUnivariate<u64, f64>rather thanUnivariate<i64, f64>, meaningBernoulli::minandBernoulli::minnow returnu64Geometricnow implementsUnivariate<u64, f64>rather thanUnivariate<i64, f64>, meaningGeometric::minandGeometric::minnow returnu64Poissonnow implementsUnivariate<u64, f64>rather thanUnivariate<i64, f64>, meaningPoisson::minandPoisson::minnow returnu64Binomialnow implementsMode<u64>instead ofMode<i64>Bernoullinow implementsMode<u64>instead ofMode<i64>Poissonnow implementsMode<u64>instead ofMode<i64>Geometricnow implementsMode<u64>instead ofMode<i64>Hypergeometricnow implementsMode<u64>instead ofMode<i64>Binomialnow implementsDiscrete<u64, f64>rather thanDiscrete<i64, f64>Bernoullinow implementsDiscrete<u64, f64>rather thanDiscrete<i64, f64>Geometricnow implementsDiscrete<u64, f64>rather thanDiscrete<i64, f64>Hypergeometricnow implementsDiscrete<u64, f64>rather thanDiscrete<i64, f64>Poissonnow implementsDiscrete<u64, f64>rather thanDiscrete<i64, f64>
-
0.5.111 Feb 2017Release notes
Open source →- Fixed critical bug in
normal::sample_uncheckedwhere it was returningNaN
- Fixed critical bug in
-
0.5.007 Feb 2017Release notes
Open source →- Implemented the
logistic::logisticspecial function - Implemented the
logistic::logitspecial function - Implemented the
factorial::multinomialspecial function - Implemented the
harmonic::harmonicspecial function - Implemented the
harmonic::gen_harmonicspecial function - Implemented the
InverseGammadistribution - Implemented the
Geometricdistribution - Implemented the
Hypergeometricdistribution gamma::gamma_urnow panics whenx > 0ora == f64::NEG_INFINITY. In addition, it also returnsf64::NANwhena == f64::INFINITYand0.0whenx == f64::INFINITYGamma::pdfandGamma::ln_pdfnow returnf64::NANif any ofshape,rate, orxaref64::INFINITYBinomial::pdfandBinomial::ln_pdfnow panic ifx > norx < 0Bernoulli::pdfandBernoulli::ln_pdfnow panic ifx > 1orx < 0
- Implemented the
-
0.4.019 Dec 2016Nothing published for this version
-
0.3.219 Nov 2016Nothing published for this version
-
0.3.115 Nov 2016Nothing published for this version
-
0.3.023 Oct 2016Nothing published for this version
-
0.2.018 Sep 2016Nothing published for this version
-
0.1.011 Aug 2016Nothing published for this version