binomtest

Crates.iobinomtest
lib.rsbinomtest
version0.1.0
created_at2025-06-04 16:02:19.251162+00
updated_at2025-06-04 16:02:19.251162+00
descriptionLightweight crate providing binomial test.
homepage
repository
max_upload_size
id1700575
size25,171
Jiří Gavenda (jirigav)

documentation

README

binomtest

binomtest is a lightweight Rust crate that provides the binomial-test function for hypothesis testing of binary outcomes.

Overview

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).

Usage

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),
    }
}

Alternative Hypothesis

The crate supports three types of alternative hypotheses through the Alternative enum:

  • TwoSided
  • Greater
  • Less

License

binomtest is released under the MIT license. See LICENSE for more information.

Commit count: 0

cargo fmt