https://github.com/statrs-dev/statrs
Statistical computation library for Rust
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 28 committers (3.6%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Keywords from Contributors
Repository
Statistical computation library for Rust
Basic Info
- Host: GitHub
- Owner: statrs-dev
- License: mit
- Language: Rust
- Default Branch: master
- Homepage: https://docs.rs/statrs/latest/statrs/
- Size: 2.83 MB
Statistics
- Stars: 729
- Watchers: 12
- Forks: 97
- Open Issues: 64
- Releases: 3
Metadata Files
README.md
statrs
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
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.
sh
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).
Precision
Floating-point numbers cannot always represent decimal values exactly, which can introduce small (and in some cases catastrophically large) errors in computations. In statistical applications, these errors can accumulate, making careful precision control important.
For Users and Evaluators
The statrs crate takes precision seriously:
- We use standardized precision checks throughout the codebase
- Default precision levels are carefully chosen to balance correctness and performance
- Module-specific precision requirements are explicitly documented where they differ from defaults
- Our test suite verifies numerical accuracy against common reference libraries
Key precision constants in the crate are set by pub consts in the prec module:
- Default relative accuracy: pub const DEFAULT_RELATIVE_ACC
- Default epsilon: pub const DEFAULT_EPS
- Default ULPs (Units in Last Place): pub const DEFAULT_ULPS
Some modules/submodules have default precision that is different from the crate defaults, for searchability the names of such constants are the MODULE_RELATIVE_ACC, MODULE_EPS, and MODULE_ULPS.
[!IMPORTANT] Starting from v0.19.0, the
precmodule is no longer public (pub mod prec→mod prec). This change reflects that precision handling is an internal implementation detail.The precision constants mentioned above remain stable and documented and will be reexported at the crate level, but direct access to the module's utilities is now restricted to maintain better API boundaries.
For Contributors
// express your sentiment about the intended use of prec module in this section. The reason is that this section is for contributors and the users need not know about internal functionality.
To help maintain consistent precision checking, statrs provides:
- A
precmodule that wraps and standardizes common approximation checks from theapproxcrate with crate-specific defaults - Macros for common precision comparison patterns
- Helper functions for convergence testing
When contributing:
- Use the provided precision utilities rather than hard-coding values
- Maintain or improve precision in existing tests when making changes, new modules can start at lesser precision than the crate defaults if need be
- when doing so, one should use the same names as defined in the prec module, this helps with searchabiliy.
- Document any module-specific precision requirements
Learning Resources
If you're new to floating-point precision, these resources provide helpful introductions:
- Comparing Floating Point Numbers, 2012 Edition
- The Floating Point Guide - Comparison
- What Every Computer Scientist Should Know About Floating-Point Arithmetic
Contributing
Thanks for your help to improve the project! No contribution is too small and all contributions are valued.
If you're not familiar with precision in floating point operations, please read the section on precision specifically, the For Contributors section.
Suggestions if you don't know where to start, - if you're an existing user, file an issue or feature request. - 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 you'd like to see in statrs - Math.NET - Distributions - Statistics - scipy.stats - KDE, see (issue #193)[https://github.com/statrs-dev/statrs/issues/193]
How to contribute
Clone the repo:
sh
git clone https://github.com/statrs-dev/statrs
Create a feature branch:
sh
git checkout -b <feature_branch> master
Write your code and docs, then ensure it is formatted:
sh
cargo fmt
Add --check to view the diff without making file changes.
Our CI will check format without making changes.
After commiting your code:
shell
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.
Communication Expectations
Please allow at least one week before pinging issues/pr's.
Owner
- Name: statrs-dev
- Login: statrs-dev
- Kind: organization
- Repositories: 1
- Profile: https://github.com/statrs-dev
GitHub Events
Total
- Issues event: 22
- Watch event: 117
- Delete event: 6
- Issue comment event: 148
- Push event: 23
- Pull request event: 46
- Pull request review comment event: 23
- Pull request review event: 34
- Fork event: 14
- Create event: 4
Last Year
- Issues event: 22
- Watch event: 117
- Delete event: 6
- Issue comment event: 148
- Push event: 23
- Pull request event: 46
- Pull request review comment event: 23
- Pull request review event: 34
- Fork event: 14
- Create event: 4
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael Ma | m****2@g****m | 419 |
| dcraven | d****l@c****h | 40 |
| Mikhail Pak | m****k@t****e | 24 |
| Vinzent Steinberg | V****g@g****m | 17 |
| Alex Sayers | a****x@a****m | 8 |
| warren | w****r@g****m | 4 |
| Michael Ma | m****a@s****m | 4 |
| Michiel De Muynck | m****k@g****m | 4 |
| Francis Beaufort | s****t@g****m | 4 |
| sminez | i****s@c****e | 3 |
| James Millard | m****n@g****m | 2 |
| Michael Ma | m****a@j****m | 2 |
| troublescooter | 2****r@u****m | 2 |
| Hoàng Xuân Phú | p****e@g****m | 1 |
| Julian Knodt | j****t@g****m | 1 |
| Andre Bogus | b****e@g****m | 1 |
| Markus Westerlind | m****1@g****m | 1 |
| Totis | 9****s@u****m | 1 |
| Davide Cavalca | d****a@f****g | 1 |
| Lars Willighagen | l****n@g****m | 1 |
| mutlusun | m****n@u****m | 1 |
| Noam Teyssier | 2****r@u****m | 1 |
| Patrick Chieppe | p****e@h****m | 1 |
| Daniel Bachler | g****b@d****m | 1 |
| W | M****R@u****m | 1 |
| doraneko94 | s****4@g****m | 1 |
| Daniel Saxton | d****n@p****e | 1 |
| sphqxe | s****t@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 111
- Total pull requests: 255
- Average time to close issues: about 1 year
- Average time to close pull requests: 3 months
- Total issue authors: 65
- Total pull request authors: 54
- Average comments per issue: 2.53
- Average comments per pull request: 2.74
- Merged pull requests: 191
- Bot issues: 0
- Bot pull requests: 8
Past Year
- Issues: 22
- Pull requests: 90
- Average time to close issues: about 2 months
- Average time to close pull requests: 15 days
- Issue authors: 13
- Pull request authors: 13
- Average comments per issue: 0.5
- Average comments per pull request: 2.82
- Merged pull requests: 64
- Bot issues: 0
- Bot pull requests: 4
Top Authors
Issue Authors
- YeungOnion (23)
- boxtown (10)
- FreezyLemon (4)
- troublescooter (4)
- tessob (2)
- saona-raimundo (2)
- vks (2)
- vi (2)
- drtconway (2)
- ghost (2)
- robinpaul85 (2)
- humphreylee (2)
- noamteyssier (2)
- wiseaidev (1)
- Magnetuz (1)
Pull Request Authors
- FreezyLemon (77)
- YeungOnion (70)
- dependabot[bot] (8)
- vks (7)
- henryjac (7)
- Qazalbash (5)
- troublescooter (4)
- WarrenWeckesser (4)
- mdahlin (4)
- soumyasen1809 (4)
- KOVALW (3)
- rikhuijzer (2)
- SabrinaJewson (2)
- tessob (2)
- dsaxton (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- approx 0.5.0
- lazy_static 1.4.0
- nalgebra 0.29
- num-traits 0.2.14
- rand 0.8
- actions-rs/toolchain v1 composite
- actions/checkout v2 composite