Created
April 11, 2019 14:27
-
-
Save AllenDowney/000141a3e9c2fc81b758ba41991d09e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Implementing CDFs\n", | |
"\n", | |
"Copyright 2019 Allen Downey\n", | |
"\n", | |
"BSD 3-clause license: https://opensource.org/licenses/BSD-3-Clause" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline\n", | |
"\n", | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"\n", | |
"import seaborn as sns\n", | |
"sns.set_style('white')\n", | |
"\n", | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import inspect\n", | |
"\n", | |
"def psource(obj):\n", | |
" \"\"\"Prints the source code for a given object.\n", | |
"\n", | |
" obj: function or method object\n", | |
" \"\"\"\n", | |
" print(inspect.getsource(obj))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Constructor\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/11).\n", | |
"\n", | |
"The `Cdf` class inherits from `pd.Series`. The `__init__` method is essentially unchanged, but it includes a workaround for what I think is bad behavior." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def __init__(self, *args, **kwargs):\n", | |
" \"\"\"Initialize a Cdf.\n", | |
"\n", | |
" Note: this cleans up a weird Series behavior, which is\n", | |
" that Series() and Series([]) yield different results.\n", | |
" See: https://github.com/pandas-dev/pandas/issues/16737\n", | |
" \"\"\"\n", | |
" if args:\n", | |
" super().__init__(*args, **kwargs)\n", | |
" else:\n", | |
" underride(kwargs, dtype=np.float64)\n", | |
" super().__init__([], **kwargs)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"from empyrical_dist import Cdf\n", | |
"\n", | |
"psource(Cdf.__init__)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"You can create an empty `Cdf` and then add elements.\n", | |
"\n", | |
"Here's a `Cdf` that representat a four-sided die." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"d4 = Cdf()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"d4[1] = 1\n", | |
"d4[2] = 2\n", | |
"d4[3] = 3\n", | |
"d4[4] = 4" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>4</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 1\n", | |
"2 2\n", | |
"3 3\n", | |
"4 4\n", | |
"dtype: int64" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"In a normalized `Cdf`, the last probability is 1.\n", | |
"\n", | |
"`normalize` makes that true. The return value is the total probability before normalizing." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def normalize(self):\n", | |
" \"\"\"Make the probabilities add up to 1 (modifies self).\n", | |
"\n", | |
" :return: normalizing constant\n", | |
" \"\"\"\n", | |
" total = self.ps[-1]\n", | |
" self /= total\n", | |
" return total\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.normalize)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"4" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.normalize()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now the Cdf is normalized." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Properties\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/2).\n", | |
"\n", | |
"In a `Cdf` the index contains the quantities (`qs`) and the values contain the probabilities (`ps`).\n", | |
"\n", | |
"These attributes are available as properties that return arrays (same semantics as the Pandas `values` property)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([1, 2, 3, 4])" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.qs" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([0.25, 0.5 , 0.75, 1. ])" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.ps" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Sharing\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/12).\n", | |
"\n", | |
"Because `Cdf` is a `Series` you can initialize it with any type `Series.__init__` can handle.\n", | |
"\n", | |
"Here's an example with a dictionary." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>a</th>\n", | |
" <td>0.333333</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>b</th>\n", | |
" <td>0.666667</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>c</th>\n", | |
" <td>1.000000</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"a 0.333333\n", | |
"b 0.666667\n", | |
"c 1.000000\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d = dict(a=1, b=2, c=3)\n", | |
"cdf = Cdf(d)\n", | |
"cdf.normalize()\n", | |
"cdf" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Here's an example with two lists." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"qs = [1,2,3,4]\n", | |
"ps = [0.25, 0.5, 0.75, 1.0]\n", | |
"d4 = Cdf(ps, index=qs)\n", | |
"d4" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"You can copy a `Cdf` like this." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4_copy = Cdf(d4)\n", | |
"d4_copy" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"However, you have to be careful about sharing. In this example, the copies share the arrays:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.index is d4_copy.index" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.ps is d4_copy.ps" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"You can avoid sharing with `copy=True`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4_copy = Cdf(d4, copy=True)\n", | |
"d4_copy" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.index is d4_copy.index" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.ps is d4_copy.ps" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Or by calling `copy` explicitly." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4_copy = d4.copy()\n", | |
"d4_copy" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.index is d4_copy.index" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.ps is d4_copy.ps" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Displaying CDFs\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/13).\n", | |
"\n", | |
"`Cdf` provides `_repr_html_`, so it looks good when displayed in a notebook." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def _repr_html_(self):\n", | |
" \"\"\"Returns an HTML representation of the series.\n", | |
"\n", | |
" Mostly used for Jupyter notebooks.\n", | |
" \"\"\"\n", | |
" df = pd.DataFrame(dict(probs=self))\n", | |
" return df._repr_html_()\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf._repr_html_)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`Cdf` provides `plot`, which plots the Cdf as a line." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def plot(self, **options):\n", | |
" \"\"\"Plot the Cdf as a line.\n", | |
"\n", | |
" :param options: passed to plt.plot\n", | |
" :return:\n", | |
" \"\"\"\n", | |
" underride(options, label=self.name)\n", | |
" plt.plot(self.qs, self.ps, **options)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.plot)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def decorate_dice(title):\n", | |
" \"\"\"Labels the axes.\n", | |
" \n", | |
" title: string\n", | |
" \"\"\"\n", | |
" plt.xlabel('Outcome')\n", | |
" plt.ylabel('CDF')\n", | |
" plt.title(title)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XeAVOXZ9/EvS1vK0qv0egHSpEgRFWNXFBB94qOxkBDFxBRNBIwlWB4L0RgTQwwajSZEoywgimKvINbILot7wdJ7hwV22Tbz/jFL3gkBlrJnZ2fm9/mHOeeemXMdbtjfnnPmXFMlHA4jIiLJKyXWBYiISGwpCEREkpyCQEQkySkIRESSnIJARCTJKQhERJJctVgXIFLRzGw8cBNQHQgDXwN3uPuagLY3AJjh7u1Lt93A3R8KYlsix0NBIEnFzB4B+gAj3H2tmaUA3wM+NbNB7r4uyO27+5NBvr/I8VAQSNIws9bAeKCNu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muDN0lgulgsIpLkdEQgIpLkFAQiIklOQSAikuQUBCIiSU5BICKS5BQEIiJJTkEgIpLk/h+jnlUza5FFcgAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"d4.plot()\n", | |
"decorate_dice('One die')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`Cdf` also provides `step`, which plots the Cdf as a step function." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def step(self, **options):\n", | |
" \"\"\"Plot the Cdf as a step function.\n", | |
"\n", | |
" :param options: passed to plt.step\n", | |
" :return:\n", | |
" \"\"\"\n", | |
" underride(options, label=self.name, where='post')\n", | |
" plt.step(self.qs, self.ps, **options)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.step)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAE95JREFUeJzt3Xu0lXWdx/H3wZhojJMpTTJoZSv9jkwFKQUYOlphyWQw2U3LjIlJSqcLU1662mV1cWIqa1Fp45SNl0wlsCa0rMYEMS+jIci3TjPeSJtsKWgoCof5Y+/TPJ0OZ5+DPGez+b1fa7ncz/N79v59H39LPvyea9fWrVuRJJVrVLsLkCS1l0EgSYUz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6se575Jw2YQqDiZ+RCNt1t9MCKWR8R1NA71HAt8DXhPRPwQmFD52grgPOBOYBmwnMYLQs7PzFuAi5vrfgbcDnxnCHXcQmM2cE1E3EBjRrKzPuBNuzBPFktS4ZwRSFLhDAJJKpxBIEmFMwgkqXAGgSQVziCQpMIZBJJUuP8DqSzxKIuqNt4AAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"d4.step()\n", | |
"decorate_dice('One die')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Make Cdf from sequence\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/14).\n", | |
"\n", | |
"\n", | |
"The following function makes a `Cdf` object from a sequence of values." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" @staticmethod\n", | |
" def from_seq(seq, normalize=True, sort=True, **options):\n", | |
" \"\"\"Make a CDF from a sequence of values.\n", | |
"\n", | |
" seq: any kind of sequence\n", | |
" normalize: whether to normalize the Cdf, default True\n", | |
" sort: whether to sort the Cdf by values, default True\n", | |
" options: passed to the pd.Series constructor\n", | |
"\n", | |
" :return: CDF object\n", | |
" \"\"\"\n", | |
" pmf = Pmf.from_seq(seq, normalize=False, sort=sort, **options)\n", | |
" return pmf.make_cdf(normalize=normalize)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.from_seq)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>a</th>\n", | |
" <td>0.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>e</th>\n", | |
" <td>0.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>l</th>\n", | |
" <td>0.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>n</th>\n", | |
" <td>1.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"a 0.2\n", | |
"e 0.4\n", | |
"l 0.8\n", | |
"n 1.0\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 30, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"cdf = Cdf.from_seq(list('allen'))\n", | |
"cdf" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>1.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.2\n", | |
"2 0.6\n", | |
"3 0.8\n", | |
"5 1.0\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 31, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"cdf = Cdf.from_seq(np.array([1, 2, 2, 3, 5]))\n", | |
"cdf" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Selection\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/15).\n", | |
"\n", | |
"`Cdf` inherits [] from Series, so you can look up a quantile and get its cumulative probability." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.25" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4[1]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.0" | |
] | |
}, | |
"execution_count": 33, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4[4]" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`Cdf` objects are mutable, but in general the result is not a valid Cdf." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.25</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.50</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.75</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1.00</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>1.25</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.25\n", | |
"2 0.50\n", | |
"3 0.75\n", | |
"4 1.00\n", | |
"5 1.25\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4[5] = 1.25\n", | |
"d4" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>probs</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>0.8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>1.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"1 0.2\n", | |
"2 0.4\n", | |
"3 0.6\n", | |
"4 0.8\n", | |
"5 1.0\n", | |
"dtype: float64" | |
] | |
}, | |
"execution_count": 35, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d4.normalize()\n", | |
"d4" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Evaluating CDFs\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/16).\n", | |
"\n", | |
"Evaluating a `Cdf` forward maps from a quantity to its cumulative probability." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"d6 = Cdf.from_seq([1,2,3,4,5,6])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(0.5)" | |
] | |
}, | |
"execution_count": 37, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.forward(3)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`forward` interpolates, so it works for quantities that are not in the distribution." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(0.5)" | |
] | |
}, | |
"execution_count": 38, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.forward(3.5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 39, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(0.)" | |
] | |
}, | |
"execution_count": 39, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.forward(0)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(1.)" | |
] | |
}, | |
"execution_count": 40, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.forward(7)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`__call__` is a synonym for `forward`, so you can call the `Cdf` like a function (which it is)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 41, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(0.16666667)" | |
] | |
}, | |
"execution_count": 41, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6(1.5)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`forward` can take an array of quantities, too." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def decorate_cdf(title):\n", | |
" \"\"\"Labels the axes.\n", | |
" \n", | |
" title: string\n", | |
" \"\"\"\n", | |
" plt.xlabel('Quantity')\n", | |
" plt.ylabel('CDF')\n", | |
" plt.title(title)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAHKxJREFUeJzt3XuUXGWZ7/FvdafTnaQ7F3JPuCTh8uSCROWWcFOXRgQVOc64xlEZCIOaGT06suYg6oyXOa7D8WCcGWUYjxwU8TKKgSjoTMABHCSQAYGR0JU8SbhEoDpXkq5OJ92d7qrzx64ORZN0Vye9+9296/dZi0XtS9V+cqtf7/fd7/tmisUiIiJSvWpCFyAiImEpCEREqpyCQESkyikIRESqnIJARKTKKQhERKrcqNAFSPUysyLwDNBTtvt37n5NoJJew8zOAla5+5yYr/Mb4CZ3X3WU7383cK67f9HMLgPe4e6fGsoaJd0UBBLa29x9V+giRrizgeMA3P1u4O6w5chIoyCQRDKzC4EbgbFAF/A37r7GzK4C/hwYB7QCpwNL3X2LmX0OWOHuJ5U+49+BlcAe4P8A9cBM4Nfu/udmNgf4LbABmAO8Bbgc+Ezps9f3U995wNdKdfQAX3H3X5rZI8BKd7+zdN7XSm/5O+CfgVOByUAb8CF397LPnAM84+6NfbfNbNzh3g9MBFYAtWbWCmwG/tjd32Nmx5feMwfIAN939xtLn3s/8K/AucAk4Dp3X93vH4qklvoIJLQHzey/yv6bZmaTgVXAp939DOBK4IdmNrf0nkXAW939bcA9wLtK+98FjDaz08xsArCY6Avv08AX3f1cYCFwmZmdWXrP8cD/dPfTgOnAl4GL3P1sogB6HTObBHwPuMLd3wy8D/hn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/UPrsl4mmFf6Guz8GHDCzhWZ2HDBXISAhqY9AqtVWYF75jtJiRicCL5ft7p2d8gAwzcz+BdgHNBJNWQHRegwALxItIlKJW4gWHvkDUROVSDAKAqlWPwDuM7O7gZ3AHcBLRHPUn0g0KdlG4M1EwXAJcIK7/4mZTQX+G6+GxOHaVwu8/o67fN8qooVRdhNNiywSjJqGpCq5+4uU2uqJ2vOnEn35jwZuB/7JzO4FaktveQyYZ2briL7En6PUGXwE/wn8bzNbULbvCeCTZva20sR3DwE73P2VofuViQyeOotFypjZGcBz7r5vGK51M7DK3R+I+1oi/VEQiARgZvcBOXe/KnQtIgoCEZEqpz4CEZEqpyAQEalyCgIRkSqnIBARqXIKAhGRKvf/AXaXpT6zNv70AAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"qs = np.linspace(0, 7)\n", | |
"ps = d6(qs)\n", | |
"plt.plot(qs, ps)\n", | |
"decorate_cdf('Forward evaluation')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`Cdf` also provides `inverse`, which computes the inverse `Cdf`:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(3.)" | |
] | |
}, | |
"execution_count": 44, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.inverse(0.5)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`quantile` is a synonym for `inverse`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array(3.)" | |
] | |
}, | |
"execution_count": 45, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.quantile(0.5)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`inverse` and `quantile` work with arrays " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGEtJREFUeJzt3XmYZXV95/F3bd1V1V1V7FuzR/mKUVFhWAQ0OiIDI4ZonIxbFEMMj/poZBzXids4gyaCzzgJ0UASxz3IEtEkLINxjCBipKOI8iUtAVRUFqWrm66qruXOH+dW9+3q6qpu7XNvV/3er+c5T92z3HO+t2i+n7PUPaer0WggSSpXd6cLkCR1lkEgSYUzCCSpcAaBJBXOIJCkwhkEklQ4g0AdFxH3RsQJna6jnSLiyIjY+Cuu47KIOL75+vKIeO7uqU6l6e10AZJ+aWcAHwPIzPM7XIuWMINAe5SIGAc+ADwPOBj448z884i4Bbg4M69qLvdBgMx8a0T8HvBaqiPcR4DXZ+ZdEfFxYB/g14AvAV8ELgF6gAZwUWZeFRErgA8Cz2rOWwu8ITNH56nvncCLmtu6t7nd1cAtwCGZuTkieoD7gecCI8AfAyubn+fGzPy9Oet8D7BfZr5+7nhEnDzf+yPifwCHAJ+OiN9t1v+nmXllRJwLvLtZ4wbgwsy8rbneI5vrOQL4MfDyzPzJTv7n0TLlqSHtaVYCD2fmM4DfBj4cEf3AZcB5AM1G+3Lg8oh4FvBK4PTMfBpV07ymZX2DmfnrmflW4L3AJZl5PPBq4DnNZd4GTAHHZ+ZxwANUYbSNZsN9MnBiZj4V+Hvg8sy8G7gTeEFz0ecB/5a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06LxZLLSLiKcA9mbmxDdu6FLgyM79c97akhRgEUgdExA3AA5n5qk7XIhkEklQ4rxFIUuEMAkkqnEEgSYUzCCSpcAaBJBXu/wMZLR1ZJB3MgQAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"ps = np.linspace(0, 1)\n", | |
"qs = d6.quantile(ps)\n", | |
"plt.plot(qs, ps)\n", | |
"decorate_cdf('Inverse evaluation')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"These functions provide a simple way to make a Q-Q plot.\n", | |
"\n", | |
"Here are two samples from the same distribution." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 47, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XeYVNX9x/H3bO8Flt4FOdJROoiKBgEVxajRqIm9JLZoYvsZo0YTY4yJJdGoMVFj7CJiQ1Q0IEWKIIhwqEtZ6u7C9t3ZKb8/7mBGWNhlmdnZ2fm8nmefnTu3fQfd+5l77r3nuPx+PyIiErviIl2AiIhEloJARCTGKQhERGKcgkBEJMYpCEREYpyCQEQkxiVEugBpuYwxjwMnBCb7AhuBqsD0KGttVZ0rNgPGmKHAm9ba7pGuJRSMMScBf7XW9o90LdL8KAgkbKy1N+57bYzJBy6y1i6OWEEiUicFgUSEMeZRoMxae7cxpgOwDTjZWvuZMeZiYLK19nxjzN3AjwEPsAa43lq7Y79tXQpcAaQDJcAZwFPA0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KWB31toeP//z+KMS7EZp4lKJGIUBBKr/g3MNMZMB3YDrwNbgfdwwqADsBo4DicYJgFdrLXnG2Pa4HQbvC8k6mpf9XHgGXfwe28CvwKKgPNC9JlEGkVNQxKTrLVbCLTV47Tnt8E5+CcBLwJ/M8Z8BMQHVlkIHGWMWYBzEN9A4GLwQXwJ/MEY0yfovSXA9caYcYHOxWYDu6y1xaH7ZCKHTxeLRYIYYwYCG/YNhBLmfT0JvGmtnRXufYkcioJAJAKMMTOBbdbaSyNdi4iCQEQkxukagYhIjFMQiIjEOAWBiEiMUxCIiMQ4BYGISIz7f6P+sI6t6QiBAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"cdf1 = Cdf.from_seq(np.random.normal(size=100))\n", | |
"cdf2 = Cdf.from_seq(np.random.normal(size=100))\n", | |
"\n", | |
"cdf1.plot()\n", | |
"cdf2.plot()\n", | |
"decorate_cdf('Two random samples')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Here's how we compute the Q-Q plot." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def qq_plot(cdf1, cdf2):\n", | |
" \"\"\"Compute results for a Q-Q plot.\n", | |
" \n", | |
" Evaluates the inverse Cdfs for all range of cumulative probabilities.\n", | |
"\n", | |
" \n", | |
" :param cdf1: Cdf\n", | |
" :param cdf2: Cdf\n", | |
" \n", | |
" :return: tuple of arrays\n", | |
" \"\"\"\n", | |
" ps = np.linspace(0, 1)\n", | |
" q1 = cdf1.quantile(ps)\n", | |
" q2 = cdf2.quantile(ps)\n", | |
" return q1, q2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The result is near the identity line, which suggests that the samples are from the same distribution." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAESCAYAAAD0aQL3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xd8lFW+x/FPSAIBCYQapIRQD70TQHRFV1SwYgdFBF3b1V27rm1d66q7el3L3bUgxQZYWGygrg1FgdAJ8KOH0AKhhZJCMnP/mOBluRAiZJ4nk/m+Xy9eYZ7MzPnlRXi+85xznnNigsEgIiISfar4XYCIiPhDASAiEqUUACIiUUoBICISpRQAIiJRSgEgIhKl4vwuQCScnHNxwJ3AlUAMoQ893wIPm9m2Ul43AHgAaAoUAluAx8zs+1/Z/iNAfTO75SjP+wIYZmY5v+b9RY6HrgCksnsL6AmcamadgW5AJvCTc67W4V7gnBsMjAUeMrP2ZtYVeAgY75w7N0x1DgzT+4ocka4ApNJyzvUGTgVamdk+ADPbDzzjnOsP3Ag8c5iXPgvcbmY/HzhgZj87524ref4nh7STCnwHTAX6ELrSuMXMph/yvI7AS0A9IAj8zczGOefeLHnKN865wWaWdXw/uUjZ6ApAKrOTgfQDJ/9DfAn0P/Sgc64O0IHQCf1wr2lf8pxDpQDfmVk34D5ggnMu/qD3jQOmAC+aWRdgEPCkc66fmY0sedppOvmLlxQAEs2O9ff/cK/bYWbvAJjZ50Ax0OWg77cFEszsw5LnbAQ+AM4+xhpEjpsCQCqzH4HezrkaAM65qs65eiXfOx342TnXyzk3/8AfM9sBLAUGHHgT51zjg16z8giDx0WHPK5CKAQOiCXU7XPoc+IR8YkCQCotM5sFfAOMKem2aQlMd859QOjT+ctmlm5m3Q78KXnpXcDfnHN9Sx7/1Tn3PfB34O4jNNfAO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nXMfmtlFJTf/1TGz78v4Hg0ILa/R2c8pgRJ9dAUglZZzrimhJThuMbOTgf6EVv58vhybGQU0BjCzA2vwXAx0KGONZxG62Sm5HGsSKRPdByCVlnPufqDAzP520LEYYDWhE/TnwI1mtsw5dyPQyMwecc49RWhxuERgqZmNdM49ArQAGhJaxOt2IAf4FNgCnAvMAnoSusu4kNBqli+ZWVpJ2xOAv5rZ7IPqGQjMBeYA7XQFIF7SFYBUZs0Jnex/YWZBQiswNjrcC5xztYAdZjYQOAno65xrUvLtAjMbBPwBuN3M5hBaUfQeM1tX8v4bgDHAc2Y2C8hzznVwztUFWhx88i95/pdmtq18flyRX0djAFKZZQItDz5QshFMCqFP7QeLKfmaBzR0zr0L7AFqErplH2Beydcsyr7e/muE9oJYR6g7SqTCUABIZTYe+MI5NwXYCkwE1gOfmNle51w+cCKwDOgBbCC08UgzM7u8ZHB2CP8XDofrLw3w/6+kDz72PnAXsA24tLx+MJHyoC4gqbTMLIuSfnhCffUNCJ3wq5Z0yfwdeNk5Nw2ILXnZLKClc+5nQifv1ZQM8h7BTOAvzrn2Bx2bA9zinDutpE//e2CLmW0vv59O5PhpEFiijnOuC7D6wIYjHrT3CvC+mX3tRXsiZaUAEAkj59wXwEYzu8bvWkQOpQAQEYlSGgMQEYlSCgARkSilABARiVIKABGRKKUAEBGJUv8Lnj94OOtN7PcAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"q1, q2 = qq_plot(cdf1, cdf2)\n", | |
"plt.plot(q1, q2)\n", | |
"plt.xlabel('Quantity 1')\n", | |
"plt.ylabel('Quantity 2')\n", | |
"plt.title('Q-Q plot');" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Here's how we compute a P-P plot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def pp_plot(cdf1, cdf2):\n", | |
" \"\"\"Compute results for a P-P plot.\n", | |
" \n", | |
" Evaluates the Cdfs for all quantities in either Cdf.\n", | |
" \n", | |
" :param cdf1: Cdf\n", | |
" :param cdf2: Cdf\n", | |
" \n", | |
" :return: tuple of arrays\n", | |
" \"\"\"\n", | |
" qs = cdf1.index.union(cdf2)\n", | |
" p1 = cdf1(qs)\n", | |
" p2 = cdf2(qs)\n", | |
" return p1, p2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"And here's what it looks like." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAESCAYAAADwnNLKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl81PWdx/FXLhKOBOS+5f4IgqigAmq9kIq1itdqrdV113rX69H1WNtau7a6rW5b7aqt1nZb61lEqdSjnlUQUe7zg0GBcN8JkDsz+8eMPIYjIUB+88vMvJ+Phw/zO5J5/0gy73x/Z1Y0GkVERDJXdtgBREQkXCoCEZEMpyIQEclwKgIRkQynIhARyXAqAhGRDJcbdgCRZDGzPsAyYH7C7Czg1+7+9D7WPxV4HXAgGl+3FrjP3f92AK/7Y6Cju9+0n/XeAi5z902N/doiTUFFIJmmwt2P/mrCzHoAC8zsM3eft4/1l+2x/nBgqpn1dfeNTZztzCb+eiKNoiKQjObuq83sc2AQsK8i2HP9uWZWDhwO7CqC+GjjA+AN4ARio4eb3P3DxM83syOB3wAdiI0yHnb3P5nZH+KrvGdmZ7t7ySFvnEgj6RiBZDQzGw0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AAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"p1, p2 = pp_plot(cdf1, cdf2)\n", | |
"plt.plot(p1, p2)\n", | |
"plt.xlabel('Cdf 1')\n", | |
"plt.ylabel('Cdf 2')\n", | |
"plt.title('P-P plot');" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Statistics\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/17).\n", | |
"\n", | |
"`Cdf` overrides the statistics methods to compute `mean`, `median`, etc." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def mean(self):\n", | |
" \"\"\"Expected value.\n", | |
"\n", | |
" :return: float\n", | |
" \"\"\"\n", | |
" return self.make_pmf().mean()\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.mean)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 53, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3.5" | |
] | |
}, | |
"execution_count": 53, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.mean()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def var(self):\n", | |
" \"\"\"Variance.\n", | |
"\n", | |
" :return: float\n", | |
" \"\"\"\n", | |
" return self.make_pmf().var()\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.var)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 55, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.916666666666667" | |
] | |
}, | |
"execution_count": 55, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.var()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 56, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def std(self):\n", | |
" \"\"\"Standard deviation.\n", | |
"\n", | |
" :return: float\n", | |
" \"\"\"\n", | |
" return self.make_pmf().std()\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.std)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 57, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.7078251276599332" | |
] | |
}, | |
"execution_count": 57, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.std()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Sampling\n", | |
"\n", | |
"For comments or questions about this section, see [this issue](https://github.com/AllenDowney/EmpyricalDistributions/issues/18).\n", | |
"\n", | |
"`choice` chooses a random values from the Cdf, following the API of `np.random.choice`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 58, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def choice(self, *args, **kwargs):\n", | |
" \"\"\"Makes a random sample.\n", | |
"\n", | |
" Uses the probabilities as weights unless `p` is provided.\n", | |
"\n", | |
" args: same as np.random.choice\n", | |
" options: same as np.random.choice\n", | |
"\n", | |
" :return: NumPy array\n", | |
" \"\"\"\n", | |
" # TODO: Make this more efficient by implementing the inverse CDF method.\n", | |
" pmf = self.make_pmf()\n", | |
" return pmf.choice(*args, **kwargs)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.choice)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 59, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([1, 1, 3, 2, 4, 1, 4, 1, 1, 6])" | |
] | |
}, | |
"execution_count": 59, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.choice(size=10)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"`sample` chooses a random values from the `Cdf`, following the API of `pd.Series.sample`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 60, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" def sample(self, *args, **kwargs):\n", | |
" \"\"\"Makes a random sample.\n", | |
"\n", | |
" Uses the probabilities as weights unless `weights` is provided.\n", | |
"\n", | |
" This function returns an array containing a sample of the quantities in this Pmf,\n", | |
" which is different from Series.sample, which returns a Series with a sample of\n", | |
" the rows in the original Series.\n", | |
"\n", | |
" args: same as Series.sample\n", | |
" options: same as Series.sample\n", | |
"\n", | |
" :return: NumPy array\n", | |
" \"\"\"\n", | |
" # TODO: Make this more efficient by implementing the inverse CDF method.\n", | |
" pmf = self.make_pmf()\n", | |
" return pmf.sample(*args, **kwargs)\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"psource(Cdf.sample)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 61, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([3, 1, 2, 5, 4, 6, 2, 2, 4, 2])" | |
] | |
}, | |
"execution_count": 61, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"d6.sample(n=10, replace=True)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment