Skip to main content

Chapter 4 Cumulative Distribution Functions

Frequency tables and PMFs are the most familiar ways to represent distributions, but as weโ€™ll see in this chapter, they have limitations. An alternative is the cumulative distribution function (CDF), which is useful for computing percentiles, and especially useful for comparing distributions.
Also in this chapter, weโ€™ll compute percentile-based statistics to quantify the location, spread, and skewness of a distribution.
Listing 4.0.1. Python Code
from os.path import basename, exists


def download(url):
    filename = basename(url)
    if not exists(filename):
        from urllib.request import urlretrieve

        local, _ = urlretrieve(url, filename)
        print("Downloaded " + local)


download("https://github.com/AllenDowney/ThinkStats/raw/v3/nb/thinkstats.py")
Listing 4.0.2. Python Code
try:
    import empiricaldist
except ImportError:
    %pip install empiricaldist
Listing 4.0.3. Python Code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from thinkstats import decorate