Skip to main content

Various calculations for binomial confidence intervals.

Project description

Binoculars: Binomial Confidence Intervals

Unit Tests codecov PyPI version

This is a small package that provides functions to compute the confidence interval for a binomial proportion. I made it because I spend altogether too much time staring at the Binomial proportion confidence interval wiki page.

Presently, the package implements:

If you haven't spent a lot of time thinking about which interval you should use (and why would you want to?), I suggest using the Wilson interval or Jeffrey's interval. Jeffrey's interval is returned by default by the binomial_confidence function in this package.

Install

pip install binoculars

Usage

from binoculars import binomial_confidence

N, p = 100, 0.2

binomial_confidence(p, N)  # default to jeffrey's interval
# (0.1307892803998113, 0.28628125447599173)

binomial_confidence(p, N, tail='lower') # grab one tail
# 0.1307892803998113

# set Z value
binomial_confidence(p, N, tail='lower', z=2.58)
# 0.11212431621448567

# choose your method

binomial_confidence(p, N, method='normal')
# (0.12160000000000001, 0.2784)

binomial_confidence(p, N, method='wilson')
# (0.1333659225590988, 0.28883096192650237)

Development

I honestly do not imagine touching this a lot. But maybe you want to add one of the other interval methods?

  1. Make a python 3.6+ venv
  2. pip install -e .[test]
  3. black lib --check
  4. pytest

Later (?)

  • [] Add confidence intervals for odds ratios, differences
  • [] Add the unimplemented intervals
  • [] Add plots comparing the intervals to readme.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binoculars-0.1.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

binoculars-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file binoculars-0.1.1.tar.gz.

File metadata

  • Download URL: binoculars-0.1.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.7

File hashes

Hashes for binoculars-0.1.1.tar.gz
Algorithm Hash digest
SHA256 69a673edf17bfe69044af66e697867b0a84f6795866599cb700389b2b69d6730
MD5 048c6393e4b3985f88476645a7934d83
BLAKE2b-256 26a5c51ad09b85d456af7034c0663f0c92efa6dad7728febf987752a8f629cdb

See more details on using hashes here.

File details

Details for the file binoculars-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: binoculars-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.7

File hashes

Hashes for binoculars-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3aaaa601b99a2f61b96035a8d5e22ee5a22fecd59586223a15a9d4433eb34fd6
MD5 e52c64b1c19a59fe8ae5addf79f00339
BLAKE2b-256 43407323f3060d989df9e3b0a15a3b330c8746b2150d5a51667a48788e7d0f04

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page