Skip to main content

confinterval

PyPI version   Python versions   License: MIT   Downloads

A lightweight Python toolkit for computing confidence intervals for means, medians, percentiles, and proportions.

It supports:

  • t confidence intervals for the mean
  • normal approximation confidence intervals for the mean
  • bootstrap confidence intervals for mean, median, standard deviation, IQR, and percentiles
  • Wilson confidence intervals for proportions

Installation

Intsall confinterval from PyPI

pip install confinterval

Quick Start

from confinterval import ci

data = [18, 19, 20, 21, 22, 20, 19, 21, 20, 22]

result = ci(data, confidence=0.95).t()

print(result)

Output:

mean: 20.2
95% t confidence interval: [19.384, 21.016]

You can also access the values directly:

result.estimate
result.lower
result.upper
result.confidence
result.method
result.statistic

Bootstrap intervals

Bootstrap intervals are useful for statistics like the median or percentiles.

from confinterval import ci

data = [18, 19, 20, 21, 22, 20, 19, 21, 20, 22]

result = ci(data, confidence=0.95, random_state=42).bootstrap("median")

print(result)

Output:

median: 20
95% bootstrap confidence interval: [19, 21]

You can use:

ci(data).bootstrap("mean")
ci(data).bootstrap("median")
ci(data).bootstrap("std")
ci(data).bootstrap("iqr")
ci(data).bootstrap("p90")
ci(data).bootstrap("p95")

Proportion intervals

Use Wilson intervals for proportions, rates, or percentages.

from confinterval import ci

result = ci.proportion(87, 100, confidence=0.95).wilson()

print(result)

This means 87 successes out of 100 total trials.

Output:

proportion: 0.87
95% wilson confidence interval: [0.790196, 0.922428]

Confidence level

The default confidence level is 95%. You can change it:

ci(data, confidence=0.90).t()
ci(data, confidence=0.99).bootstrap("median")
ci.proportion(87, 100, confidence=0.95).wilson()

Higher confidence gives a wider interval.

Convert result to dictionary

data = [18, 19, 20, 21, 22, 20, 19, 21, 20, 22]

result = ci(data).t()

result.to_dict()

Output:

{'estimate': 20.2,
 'lower': 19.25818886972757,
 'upper': 21.14181113027243,
 'confidence': 0.95,
 'method': 't',
 'statistic': 'mean'}

License

This project is under the MIT License.

Release files for confinterval 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for confinterval 0.1.1
File Size Uploaded
confinterval-0.1.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for confinterval 0.1.1
File Interpreter ABI Platform
confinterval-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / confinterval-0.1.1.tar.gz

Download URL confinterval-0.1.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dc7f50a498f7d161f62b355ff03cfec7fc3a40d6f2719c4b7b37faec5f2a8da5
BLAKE2b-256 checksum
How to use checksums
be1ffbc656d3bcc9ba94f645f0ae86e022c288aa05951bcf96ee1e9c2c69df39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release files / confinterval-0.1.1-py3-none-any.whl

Download URL confinterval-0.1.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ddfee864b2491c541f5cd97330e615c6bbca61e14d8aa24e209a3d0a28636db
BLAKE2b-256 checksum
How to use checksums
e16695128cbd76608fbce6d41854cfd8283f9c2fdc6e6f7e71c2c70b75d44365
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page