23 releases (breaking)

0.18.0 Dec 3, 2024
0.17.1 Jun 8, 2024
0.16.1 Jun 2, 2024
0.16.0 Aug 29, 2022
0.3.2 Nov 19, 2016

#3 in Math

Download history 34040/week @ 2024-08-21 35636/week @ 2024-08-28 34642/week @ 2024-09-04 33020/week @ 2024-09-11 37351/week @ 2024-09-18 46000/week @ 2024-09-25 40223/week @ 2024-10-02 45092/week @ 2024-10-09 42898/week @ 2024-10-16 41521/week @ 2024-10-23 39982/week @ 2024-10-30 36523/week @ 2024-11-06 38721/week @ 2024-11-13 40972/week @ 2024-11-20 40447/week @ 2024-11-27 38454/week @ 2024-12-04

164,629 downloads per month
Used in 691 crates (165 directly)

MIT license

785KB
15K SLoC

statrs

tests MIT licensed Crate docs.rs codecov-statrs Crates.io MSRV

Statrs provides a host of statistical utilities for Rust scientific computing.

Included are a number of common distributions that can be sampled (i.e. Normal, Exponential, Student's T, Gamma, Uniform, etc.) plus common statistical functions like the gamma function, beta function, and error function.

This library began as port of the statistical capabilities in the C# Math.NET library. All unit tests in the library borrowed from Math.NET when possible and filled-in when not. Planned for future releases are continued implementations of distributions as well as porting over more statistical utilities.

Please check out the documentation here.

Usage

Add the most recent release to your Cargo.toml

[dependencies]
statrs = "*" # replace * by the latest version of the crate.

For examples, view the docs.

Running tests

If you'd like to run all suggested tests, you'll need to download some data from NIST, we have a script for this and formatting the data in the tests/ folder.

cargo test
./tests/gather_nist_data.sh && cargo test -- --include-ignored nist_

If you'd like to modify where the data is downloaded, you can use the environment variable, STATRS_NIST_DATA_DIR for running the script and the tests.

Minimum supported Rust version (MSRV)

This crate requires a Rust version of 1.65.0 or higher. Increases in MSRV will be considered a semver non-breaking API change and require a version increase (PATCH until 1.0.0, MINOR after 1.0.0).

Contributing

Thanks for your help to improve the project! No contribution is too small and all contributions are valued.

Suggestions if you don't know where to start,

  • documentation is a great place to start, as you'll be able to identify the value of existing documentation better than its authors.
  • tests are valuable in demonstrating correct behavior, you can review test coverage on the CodeCov Report
  • check out some of the issues marked help wanted.
  • look at features in other tools you'd like to see in statrs

How to contribute

Clone the repo:

git clone https://github.com/statrs-dev/statrs

Create a feature branch:

git checkout -b <feature_branch> master

Write your code and docs, then ensure it is formatted:

cargo fmt

Add --check to view the diff without making file changes. Our CI will check format without making changes.

After commiting your code:

git push -u <your_remote_name> <your_branch> # with `git`
gh pr create --head <your_branch> # with GitHub's cli

Then submit a PR, preferably referencing the relevant issue, if it exists.

Commit messages

Please be explicit and and purposeful with commit messages. Conventional Commits encouraged.

Bad

Modify test code

Good

test: Update statrs::distribution::Normal test_cdf

Communication Expectations

Please allow at least one week before pinging issues/pr's.

Dependencies

~5MB
~104K SLoC