SkillAgentSearch skills...

Empiricaldist

Python library that represents empirical distribution functions.

Install / Use

/learn @AllenDowney/Empiricaldist
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

empiricaldist

empiricaldist is a Python library that provides classes to represent empirical distributions -- that is, distributions based on data rather than mathematical functions. It includes four equivalent ways to represent a distribution: PMF (Probability Mass Function), CDF (Cumulative Distribution Function), Survival function and Hazard Function. It provides methods to convert from one representation to the others, and methods to perform a variety of operations.

This library is used extensively in Think Stats, Think Bayes, Elements of Data Science, and Think Complexity -- but it is intended to be a stand-alone library for general use, not just for my books.

Usage

Here's a quick example of how to use it:

from empiricaldist import Pmf

# Create a PMF object
pmf = Pmf.from_seq([1, 2, 2, 3, 5])

# Make the other representations
cdf = pmf.make_cdf()
surv = cdf.make_surv()
hazard = surv.make_hazard()

# Look up quantities
print(pmf(4))
print(cdf(4))
print(surv(4))
print(hazard(4))

# Cdf and Surv also provide inverse lookups
print(cdf.inverse(0.5))
print(surv.inverse(0.5))

For an introduction to the API, you can read this notebook or run it on Colab.

Installation

To install empiricaldist, use pip:

pip install empiricaldist

License

empiricaldist is available under the BSD 3-clause license. See the LICENSE file for more details.

View on GitHub
GitHub Stars175
CategoryDevelopment
Updated11d ago
Forks36

Languages

Jupyter Notebook

Security Score

95/100

Audited on Mar 26, 2026

No findings