| 1 |
# statrs |
| 2 |
|
| 3 |
![tests][actions-test-badge] |
| 4 |
[![MIT licensed][license-badge]](./LICENSE.md) |
| 5 |
[![Crate][crates-badge]][crates-url] |
| 6 |
[![docs.rs][docsrs-badge]][docs-url] |
| 7 |
[![codecov-statrs][codecov-badge]][codecov-url] |
| 8 |
![Crates.io MSRV][crates-msrv-badge] |
| 9 |
|
| 10 |
[actions-test-badge]: https://github.com/statrs-dev/statrs/actions/workflows/test.yml/badge.svg |
| 11 |
[crates-badge]: https://img.shields.io/crates/v/statrs.svg |
| 12 |
[crates-url]: https://crates.io/crates/statrs |
| 13 |
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg |
| 14 |
[docsrs-badge]: https://img.shields.io/docsrs/statrs |
| 15 |
[docs-url]: https://docs.rs/statrs/*/statrs |
| 16 |
[codecov-badge]: https://codecov.io/gh/statrs-dev/statrs/graph/badge.svg?token=XtMSMYXvIf |
| 17 |
[codecov-url]: https://codecov.io/gh/statrs-dev/statrs |
| 18 |
[crates-msrv-badge]: https://img.shields.io/crates/msrv/statrs |
| 19 |
|
| 20 |
Statrs provides a host of statistical utilities for Rust scientific computing. |
| 21 |
|
| 22 |
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. |
| 23 |
|
| 24 |
This library began as port of the statistical capabilities in the C# Math.NET library. |
| 25 |
All unit tests in the library borrowed from Math.NET when possible and filled-in when not. |
| 26 |
Planned for future releases are continued implementations of distributions as well as porting over more statistical utilities. |
| 27 |
|
| 28 |
Please check out the documentation [here][docs-url]. |
| 29 |
|
| 30 |
## Usage |
| 31 |
|
| 32 |
Add the most recent release to your `Cargo.toml` |
| 33 |
|
| 34 |
```toml |
| 35 |
[dependencies] |
| 36 |
statrs = "*" # replace * by the latest version of the crate. |
| 37 |
``` |
| 38 |
|
| 39 |
For examples, view [the docs](https://docs.rs/statrs/*/statrs/). |
| 40 |
|
| 41 |
### Running tests |
| 42 |
|
| 43 |
If you'd like to run all suggested tests, you'll need to download some data from |
| 44 |
NIST, we have a script for this and formatting the data in the `tests/` folder. |
| 45 |
|
| 46 |
```sh |
| 47 |
cargo test |
| 48 |
./tests/gather_nist_data.sh && cargo test -- --include-ignored nist_ |
| 49 |
``` |
| 50 |
|
| 51 |
If you'd like to modify where the data is downloaded, you can use the environment variable, |
| 52 |
`STATRS_NIST_DATA_DIR` for running the script and the tests. |
| 53 |
|
| 54 |
## Minimum supported Rust version (MSRV) |
| 55 |
|
| 56 |
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). |
| 57 |
|
| 58 |
## Contributing |
| 59 |
|
| 60 |
Thanks for your help to improve the project! |
| 61 |
**No contribution is too small and all contributions are valued.** |
| 62 |
|
| 63 |
Suggestions if you don't know where to start, |
| 64 |
- [documentation][docs-url] is a great place to start, as you'll be able to identify the value of existing documentation better than its authors. |
| 65 |
- tests are valuable in demonstrating correct behavior, you can review test coverage on the [CodeCov Report][codecov-url] |
| 66 |
- check out some of the issues marked [help wanted](https://github.com/statrs-dev/statrs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). |
| 67 |
- look at features in other tools you'd like to see in statrs |
| 68 |
- Math.NET's |
| 69 |
- [Distributions](https://github.com/mathnet/mathnet-numerics/tree/master/src/Numerics/Distributions) |
| 70 |
- [Statistics](https://github.com/mathnet/mathnet-numerics/tree/master/src/Numerics/Statistics) |
| 71 |
- scipy.stats |
| 72 |
|
| 73 |
### How to contribute |
| 74 |
|
| 75 |
Clone the repo: |
| 76 |
|
| 77 |
``` |
| 78 |
git clone https://github.com/statrs-dev/statrs |
| 79 |
``` |
| 80 |
|
| 81 |
Create a feature branch: |
| 82 |
|
| 83 |
``` |
| 84 |
git checkout -b <feature_branch> master |
| 85 |
``` |
| 86 |
|
| 87 |
Write your code and docs, then ensure it is formatted: |
| 88 |
|
| 89 |
``` |
| 90 |
cargo fmt |
| 91 |
``` |
| 92 |
|
| 93 |
Add `--check` to view the diff without making file changes. |
| 94 |
Our CI will check format without making changes. |
| 95 |
|
| 96 |
After commiting your code: |
| 97 |
|
| 98 |
```shell |
| 99 |
git push -u <your_remote_name> <your_branch> # with `git` |
| 100 |
gh pr create --head <your_branch> # with GitHub's cli |
| 101 |
``` |
| 102 |
|
| 103 |
Then submit a PR, preferably referencing the relevant issue, if it exists. |
| 104 |
|
| 105 |
### Commit messages |
| 106 |
|
| 107 |
Please be explicit and and purposeful with commit messages. |
| 108 |
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) encouraged. |
| 109 |
|
| 110 |
#### Bad |
| 111 |
|
| 112 |
``` |
| 113 |
Modify test code |
| 114 |
``` |
| 115 |
|
| 116 |
#### Good |
| 117 |
|
| 118 |
``` |
| 119 |
test: Update statrs::distribution::Normal test_cdf |
| 120 |
``` |
| 121 |
|
| 122 |
### Communication Expectations |
| 123 |
|
| 124 |
Please allow at least one week before pinging issues/pr's. |
| 125 |
|