| Crates.io | binomtest |
| lib.rs | binomtest |
| version | 0.1.0 |
| created_at | 2025-06-04 16:02:19.251162+00 |
| updated_at | 2025-06-04 16:02:19.251162+00 |
| description | Lightweight crate providing binomial test. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1700575 |
| size | 25,171 |
binomtest is a lightweight Rust crate that provides the binomial-test function for hypothesis testing of binary outcomes.
The binomial_test function calculates the p-value for the binomial test given:
The number of observed successes,
The total number of trials,
The hypothesized probability of success under the null hypothesis,
The alternative hypothesis type (two-sided, greater, or less).
Add the crate to your Cargo.toml:
[dependencies]
binomial-test = "0.1.0"
Use the function in your Rust code:
use binomtest::*;
fn main() {
let successes = 5;
let trials = 10;
let p_null = 0.5;
let alt = Alternative::TwoSided;
match binomial_test(successes, trials, p_null, alt) {
Ok(p_value) => println!("P-value: {}", p_value),
Err(e) => eprintln!("Error: {}", e),
}
}
The crate supports three types of alternative hypotheses through the Alternative enum:
binomtest is released under the MIT license. See LICENSE for more information.