Coder Social home page Coder Social logo

eigenein / bpci Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 43 KB

Binomial proportion confidence intervals

Home Page: https://lib.rs/crates/bpci

License: MIT License

Makefile 0.33% Rust 99.67%
crate mathematics rust rust-library statistics binomial proportions wilson-score agresti-coull wald-interval

bpci's Introduction

bpci

Binomial proportion confidence intervals.

Crates.io Last commit GitHub Workflow Status License: MIT docs.rs

Samples

By size and number of successes

use bpci::NSuccessesSample;

fn main() {
    // 10 successes out of 20 trials:
    let sample = NSuccessesSample::new(20, 10).unwrap();
}

By size and proportion

use bpci::ProportionSample;

fn main() {
    // 20 trials with 0.5 success rate:
    let sample = ProportionSample::new(20, 0.5).unwrap();
}

Intervals

use bpci::*;
use approx::assert_relative_eq;

fn main() {
    let sample = ProportionSample::new(100, 0.25).unwrap();
    let interval = sample.wilson_score(1.960); // 95%
    assert_relative_eq!(interval.lower(), 0.1754509400372426);
    assert_relative_eq!(interval.upper(), 0.3430464637007583);
}
use bpci::*;
use approx::assert_relative_eq;

fn main() {
    let sample = ProportionSample::new(100, 0.25).unwrap();
    let interval = sample.wilson_score_with_cc(1.960); // 95%
    assert_relative_eq!(interval.lower(), 0.17117438961361867);
    assert_relative_eq!(interval.upper(), 0.34838596518606424);
}
use bpci::*;
use approx::assert_relative_eq;

fn main() {
    let sample = ProportionSample::new(40, 0.25).unwrap();
    let interval = sample.agresti_coull(1.960); // 95%
    assert_relative_eq!(interval.mean, 0.2719061348125981);
    assert_relative_eq!(interval.margin, 0.1317091851034039);
}
use bpci::*;
use approx::assert_relative_eq;

fn main() {
    let sample = NSuccessesSample::new(40, 10).unwrap();
    let interval = sample.agresti_coull(1.960); // 95%
    assert_relative_eq!(interval.mean, 0.2719061348125981);
    assert_relative_eq!(interval.margin, 0.1317091851034039);
}
use bpci::*;
use approx::assert_relative_eq;

fn main() {
    let sample = ProportionSample::new(100, 0.3).unwrap();
    let interval = sample.wald(1.960); // 95%
    assert_relative_eq!(interval.lower(), 0.2101815163788655);
    assert_relative_eq!(interval.upper(), 0.38981848362113447);
}

bpci's People

Contributors

eigenein avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.