Crates.io | hypors |
lib.rs | hypors |
version | 0.2.4 |
source | src |
created_at | 2024-10-03 14:55:35.634304 |
updated_at | 2024-10-10 20:51:42.577588 |
description | Hypothesis Testing with Polars |
homepage | |
repository | https://github.com/astronights/hypors |
max_upload_size | |
id | 1395307 |
size | 115,867 |
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 polars
crate for efficient data manipulation and 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.2.4"
Note HypoRS relies on the following dependencies, which will be automatically included:
serde (version >=1.0.210)
statrs (version >=0.17.1)
polars (version >=0.43.1)
Here are some examples of running tests with Rust.
use polars::prelude::*;
use hypors::{t::t_test, common::TailType};
let data = Series::new("sample", &[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 polars::prelude::*;
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);
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.