| Crates.io | hypors |
| lib.rs | hypors |
| version | 0.3.0 |
| created_at | 2024-10-03 14:55:35.634304+00 |
| updated_at | 2025-08-02 04:15:51.288728+00 |
| description | Hypothesis Testing with Rust |
| homepage | |
| repository | https://github.com/astronights/hypors |
| max_upload_size | |
| id | 1395307 |
| size | 140,970 |
hypors is a Rust library designed for performing a variety of hypothesis tests, including t-tests, z-tests, proportion tests, ANOVA, Chi-square tests, and Mann-Whitney tests. This library leverages the statrs crate for statistical distributions.
Rust Crate: https://crates.io/crates/hypors
PyPI Package: Work in Progress
Hypothesis testing is available for this suite of common distributions.
All parametrized distributions have respective modules to calculate minimum sample size required with customizable parameters for alpha and statistical power.
To use this library in your Rust project, add the following to your Cargo.toml:
[dependencies]
hypors = "0.3.0"
Note HypoRS relies on the following dependencies, which will be automatically included:
serde (version >=1.0.210)
statrs (version >=0.17.1)
Here are some examples of running tests with Rust.
use hypors::{t::t_test, common::TailType};
let data = vec![1.2, 2.3, 1.9, 2.5, 2.8];
let population_mean = 2.0;
let tail = TailType::Two;
let alpha = 0.05;
let result = t_test(data, population_mean, tail, alpha).unwrap();
println!("Test Statistic: {}", result.test_statistic);
println!("p-value: {}", result.p_value);
println!("Confidence Interval: {}", result.confidence_interval);
println!("Null Hypothesis: {}", result.null_hypothesis);
println!("Alternate Hypothesis: {}", result.alt_hypothesis);
println!("Reject Null Hypothesis?: {}", result.reject_null);
use hypors::{chi_square::independence};
let observed = vec![10, 20, 30]; // Observed frequencies
let expected = vec![15, 15, 30]; // Expected frequencies
let result = independece(observed, expected).unwrap();
println!("Chi-Square Statistic: {}", result.test_statistic);
println!("p-value: {}", result.p_value);
println!("Null Hypothesis: {}", result.null_hypothesis);
println!("Alternate Hypothesis: {}", result.alt_hypothesis);
println!("Reject Null Hypothesis?: {}", result.reject_null);
With the polars crate having frequent minor version updates, this library has been updated to not use Polars inherently, and relies on Vec types.
Any use of polars Series types should be converted before and after using the hypors functions.
Polars to Vec Conversion:
use polars::prelude::*;
let series = Series::new("series_name", &[1, 2, 3, 4, 5]);
let vec = series.to_vec().unwrap();
Vec to Polars Conversion:
use polars::prelude::*;
let vec = vec![1, 2, 3, 4, 5];
let series = Series::new("series_name", vec);
Work in Progress
The next step for hypors is to add Python bindings to make it accessible to the Python community. This work is currently in progress. Stay tuned for updates!
Contributions are always welcome! If you have suggestions for improvements, bug fixes, or new features, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.