{"id":15564033,"url":"https://github.com/eigenein/bpci","last_synced_at":"2025-09-20T10:32:32.017Z","repository":{"id":50465899,"uuid":"518972887","full_name":"eigenein/bpci","owner":"eigenein","description":"Binomial proportion confidence intervals","archived":false,"fork":false,"pushed_at":"2022-12-02T23:01:24.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-10T20:14:29.269Z","etag":null,"topics":["agresti-coull","binomial","crate","mathematics","proportions","rust","rust-library","statistics","wald-interval","wilson-score"],"latest_commit_sha":null,"homepage":"https://lib.rs/crates/bpci","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eigenein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-28T19:36:15.000Z","updated_at":"2023-03-24T14:00:59.000Z","dependencies_parsed_at":"2023-01-23T13:15:59.011Z","dependency_job_id":null,"html_url":"https://github.com/eigenein/bpci","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigenein%2Fbpci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigenein%2Fbpci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigenein%2Fbpci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigenein%2Fbpci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eigenein","download_url":"https://codeload.github.com/eigenein/bpci/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233582501,"owners_count":18697862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agresti-coull","binomial","crate","mathematics","proportions","rust","rust-library","statistics","wald-interval","wilson-score"],"created_at":"2024-10-02T16:34:47.071Z","updated_at":"2025-09-20T10:32:26.647Z","avatar_url":"https://github.com/eigenein.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `bpci`\n\nBinomial proportion confidence intervals.\n\n[![Crates.io](https://img.shields.io/crates/v/bpci)](https://crates.io/crates/bpci)\n[![Last commit](https://img.shields.io/github/last-commit/eigenein/bpci)](https://github.com/eigenein/bpci/commits/master)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/eigenein/bpci/Check)](https://github.com/eigenein/bpci/actions)\n![License: MIT](https://img.shields.io/crates/l/bpci)\n[![docs.rs](https://img.shields.io/docsrs/bpci)](https://docs.rs/bpci)\n\n## Samples\n\n### By size and number of successes\n\n```rust\nuse bpci::NSuccessesSample;\n\nfn main() {\n    // 10 successes out of 20 trials:\n    let sample = NSuccessesSample::new(20, 10).unwrap();\n}\n```\n\n### By size and proportion\n\n```rust\nuse bpci::ProportionSample;\n\nfn main() {\n    // 20 trials with 0.5 success rate:\n    let sample = ProportionSample::new(20, 0.5).unwrap();\n}\n```\n\n## Intervals\n\n### [Wilson score interval](https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Wilson_score_interval)\n\n```rust\nuse bpci::*;\nuse approx::assert_relative_eq;\n\nfn main() {\n    let sample = ProportionSample::new(100, 0.25).unwrap();\n    let interval = sample.wilson_score(1.960); // 95%\n    assert_relative_eq!(interval.lower(), 0.1754509400372426);\n    assert_relative_eq!(interval.upper(), 0.3430464637007583);\n}\n```\n\n### [Wilson score interval with continuity correction](https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Wilson_score_interval_with_continuity_correction)\n\n```rust\nuse bpci::*;\nuse approx::assert_relative_eq;\n\nfn main() {\n    let sample = ProportionSample::new(100, 0.25).unwrap();\n    let interval = sample.wilson_score_with_cc(1.960); // 95%\n    assert_relative_eq!(interval.lower(), 0.17117438961361867);\n    assert_relative_eq!(interval.upper(), 0.34838596518606424);\n}\n```\n\n### [Agresti–Coull interval](https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Agresti%E2%80%93Coull_interval)\n\n```rust\nuse bpci::*;\nuse approx::assert_relative_eq;\n\nfn main() {\n    let sample = ProportionSample::new(40, 0.25).unwrap();\n    let interval = sample.agresti_coull(1.960); // 95%\n    assert_relative_eq!(interval.mean, 0.2719061348125981);\n    assert_relative_eq!(interval.margin, 0.1317091851034039);\n}\n```\n\n```rust\nuse bpci::*;\nuse approx::assert_relative_eq;\n\nfn main() {\n    let sample = NSuccessesSample::new(40, 10).unwrap();\n    let interval = sample.agresti_coull(1.960); // 95%\n    assert_relative_eq!(interval.mean, 0.2719061348125981);\n    assert_relative_eq!(interval.margin, 0.1317091851034039);\n}\n```\n\n### [Normal approximation interval or Wald interval](https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Normal_approximation_interval_or_Wald_interval)\n\n```rust\nuse bpci::*;\nuse approx::assert_relative_eq;\n\nfn main() {\n    let sample = ProportionSample::new(100, 0.3).unwrap();\n    let interval = sample.wald(1.960); // 95%\n    assert_relative_eq!(interval.lower(), 0.2101815163788655);\n    assert_relative_eq!(interval.upper(), 0.38981848362113447);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigenein%2Fbpci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feigenein%2Fbpci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigenein%2Fbpci/lists"}