{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cda9983c",
   "metadata": {},
   "source": [
    "$$\n",
    "\\newcommand{\\argmax}{arg\\,max}\n",
    "\\newcommand{\\argmin}{arg\\,min}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0feec66e",
   "metadata": {},
   "source": [
    "# Probability Distributions\n",
    "\n",
    "\n",
    "<a id='index-0'></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ec6b0fc",
   "metadata": {},
   "source": [
    "## Outline\n",
    "\n",
    "In data science applications, we are often interested in data on a specific variable.\n",
    "\n",
    "In this lecture we give a quick introduction to probability distributions using Python.\n",
    "\n",
    "This lecture is the first of three.\n",
    "\n",
    "The second, [Observed Distributions](https://intro.quantecon.org/observed_distributions.html), treats observed data — sets of\n",
    "numbers that we measure or collect — and its connection to the probability\n",
    "distributions studied here.\n",
    "\n",
    "The third, [Fitting Distributions to Data](https://intro.quantecon.org/fitting_distributions.html), asks which probability distribution\n",
    "best describes a given data set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dd558374",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import scipy.stats\n",
    "\n",
    "np.set_printoptions(legacy='1.25')   # print scalars as plain numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a14487ed",
   "metadata": {},
   "source": [
    "To motivate what follows, let’s start with a real example: the heights of adult men and women in the United States.\n",
    "\n",
    "The data come from the US [National Health and Nutrition Examination Survey](https://www.cdc.gov/nchs/nhanes/index.htm) (NHANES).\n",
    "\n",
    "The next figure shows histograms of the two datasets, with heights measured in centimeters."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28e1f234",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "url = ('https://github.com/QuantEcon/data-lectures/raw/main/'\n",
    "       'lectures/us_adult_heights.csv')\n",
    "heights = pd.read_csv(url)\n",
    "male = heights[heights['sex'] == 'male']['height_cm']\n",
    "female = heights[heights['sex'] == 'female']['height_cm']\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.hist(male, bins=40, density=True, alpha=0.6, label='male')\n",
    "ax.hist(female, bins=40, density=True, alpha=0.6, label='female')\n",
    "ax.set_xlabel('height (cm)')\n",
    "ax.set_ylabel('density')\n",
    "ax.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd38cb32",
   "metadata": {},
   "source": [
    "Each histogram has the familiar “bell” shape.\n",
    "\n",
    "This suggests that we can approximate the data using a **normal distribution** — a continuous distribution with a bell-shaped density that we study in detail below.\n",
    "\n",
    "To do so, we fit a normal distribution to each dataset, choosing its mean and standard deviation to match the sample mean and standard deviation of the heights."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "77ad6c06",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "x_grid = np.linspace(130, 205, 200)\n",
    "for sample, color, label in ((male, 'C0', 'male'), (female, 'C1', 'female')):\n",
    "    ax.hist(sample, bins=40, density=True, alpha=0.4, color=color)\n",
    "    u = scipy.stats.norm(sample.mean(), sample.std())\n",
    "    ax.plot(x_grid, u.pdf(x_grid), color=color, lw=2, label=label)\n",
    "ax.set_xlabel('height (cm)')\n",
    "ax.set_ylabel('density')\n",
    "ax.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24ef8c69",
   "metadata": {},
   "source": [
    "The fit is remarkably good.\n",
    "\n",
    "Notice what this achieves: each dataset of around 5,000 individual measurements is now summarized by a smooth density with just **two parameters** — the mean $ \\mu $, which sets the center, and the standard deviation $ \\sigma $, which sets the spread.\n",
    "\n",
    "Such compact summaries are extremely useful.\n",
    "\n",
    "They are one reason we study **common distributions**: named families of distributions, each governed by a small number of parameters, that have proven useful for describing data.\n",
    "\n",
    "We turn to these now, recalling the definitions of some well-known distributions and exploring how to manipulate them with SciPy."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "abb6b4a9",
   "metadata": {},
   "source": [
    "## Discrete distributions\n",
    "\n",
    "Let’s start with discrete distributions.\n",
    "\n",
    "A discrete distribution is defined by a set of numbers $ S = \\{x_1, \\ldots, x_n\\} $ and a **probability mass function** (PMF) on $ S $, which is a function $ p $ from $ S $ to $ [0,1] $ with the property\n",
    "\n",
    "$$\n",
    "\\sum_{i=1}^n p(x_i) = 1\n",
    "$$\n",
    "\n",
    "For example, the next figure shows the fraction of people at each age in Japan in 2024 (Japanese nationals), from 0 to 100 and over.\n",
    "\n",
    "The data come from the [Statistics Bureau of Japan](https://www.stat.go.jp/english/data/jinsui/index.html)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "893b8845",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "url = ('https://github.com/QuantEcon/data-lectures/raw/main/'\n",
    "       'lectures/japan_population_by_age.csv')\n",
    "data = pd.read_csv(url)\n",
    "age = data['age']                          # 0, 1, ..., 100 and over\n",
    "population = data['japanese_population']   # in thousands\n",
    "\n",
    "p = population / population.sum()\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.bar(age, p)\n",
    "ax.set_xlabel('age')\n",
    "ax.set_ylabel('fraction of population')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75bce9c8",
   "metadata": {},
   "source": [
    "Here each $ x_i $ is an age and $ p(x_i) $ is the fraction of the population at that age, and the fractions sum to one.\n",
    "\n",
    "We say that a random variable $ X $ **has distribution** $ p $ if $ X $ takes value $ x_i $ with probability $ p(x_i) $.\n",
    "\n",
    "That is,\n",
    "\n",
    "$$\n",
    "\\mathbb P\\{X = x_i\\} = p(x_i) \\quad \\text{for } i= 1, \\ldots, n\n",
    "$$\n",
    "\n",
    "The **mean** or **expected value** of a random variable $ X $ with distribution $ p $ is\n",
    "\n",
    "$$\n",
    "\\mathbb{E}[X] = \\sum_{i=1}^n x_i p(x_i)\n",
    "$$\n",
    "\n",
    "Expectation is also called the *first moment* of the distribution.\n",
    "\n",
    "We also refer to this number as the mean of the distribution (represented by) $ p $.\n",
    "\n",
    "More generally, if $ f $ is a function on $ S $, then $ f(X) $ is a random variable that takes the value $ f(x_i) $ whenever $ X $ takes the value $ x_i $.\n",
    "\n",
    "Its expectation is obtained by weighting each of these values by its probability:\n",
    "\n",
    "$$\n",
    "\\mathbb{E}[f(X)] = \\sum_{i=1}^n f(x_i) p(x_i)\n",
    "$$\n",
    "\n",
    "Every quantity we define below is an expectation of this form, for a suitable choice of $ f $.\n",
    "\n",
    "The **variance** of $ X $ is defined as\n",
    "\n",
    "$$\n",
    "\\mathbb{V}[X] \n",
    "    = \\mathbb{E}[(X - \\mathbb{E}[X])^2]\n",
    "    = \\sum_{i=1}^n (x_i - \\mathbb{E}[X])^2 p(x_i)\n",
    "$$\n",
    "\n",
    "Variance is also called the *second central moment* of the distribution.\n",
    "\n",
    "The **standard deviation** of $ X $ is the square root of the variance:\n",
    "\n",
    "$$\n",
    "\\sigma = \\sqrt{\\mathbb{V}[X]}\n",
    "$$\n",
    "\n",
    "We often prefer the standard deviation to the variance because it is measured in the same units as $ X $ itself.\n",
    "\n",
    "For example, if $ X $ is a height in centimeters, then $ \\sigma $ is in centimeters, while the variance is in centimeters squared.\n",
    "\n",
    "This means that $ \\sigma $ can be read directly off the horizontal axis of a histogram of the data, as a measure of spread.\n",
    "\n",
    "Means and variances are special cases of moments.\n",
    "\n",
    "Writing $ \\mu = \\mathbb{E}[X] $, the $ k $-th **moment** of $ X $ is $ \\mathbb{E}[X^k] $, while the $ k $-th **central moment** is $ \\mathbb{E}[(X - \\mu)^k] $.\n",
    "\n",
    "Thus the mean is the first moment and the variance is the second central moment.\n",
    "\n",
    "It is often convenient to work with **standardized moments**\n",
    "\n",
    "$$\n",
    "\\mathbb{E} \\left[ \\left( \\frac{X - \\mu}{\\sigma} \\right)^k \\right]\n",
    "$$\n",
    "\n",
    "which are unchanged when we shift $ X $ or rescale it.\n",
    "\n",
    "(If $ X $ is measured in centimeters, we obtain the same standardized moments after converting to inches.)\n",
    "\n",
    "The third standardized moment is called the **skewness**:\n",
    "\n",
    "$$\n",
    "S = \\mathbb{E} \\left[ \\left( \\frac{X - \\mu}{\\sigma} \\right)^3 \\right]\n",
    "$$\n",
    "\n",
    "Skewness measures asymmetry.\n",
    "\n",
    "Any distribution that is symmetric about its mean has zero skewness, while a distribution with a long right tail has positive skewness.\n",
    "\n",
    "The fourth standardized moment is called the **kurtosis**:\n",
    "\n",
    "$$\n",
    "K = \\mathbb{E} \\left[ \\left( \\frac{X - \\mu}{\\sigma} \\right)^4 \\right]\n",
    "$$\n",
    "\n",
    "Kurtosis measures how much probability mass sits far out in the tails.\n",
    "\n",
    "For *every* normal distribution, $ K = 3 $, regardless of $ \\mu $ and $ \\sigma $.\n",
    "\n",
    "Since the normal distribution is such a useful benchmark, it is common to subtract 3 and work with the **excess kurtosis**\n",
    "\n",
    "$$\n",
    "K - 3\n",
    "$$\n",
    "\n",
    "which is zero for the normal distribution.\n",
    "\n",
    "Positive excess kurtosis means more mass in the tails than the normal distribution — extreme values are more likely.\n",
    "\n",
    ">**Note**\n",
    ">\n",
    ">Take care when reading software documentation, since these two names are not always used correctly.\n",
    "\n",
    "For example, `scipy.stats.kurtosis` returns the excess kurtosis by default, rather than the kurtosis.\n",
    "\n",
    "(Set `fisher=False` to obtain the kurtosis.)\n",
    "\n",
    "We will use skewness and excess kurtosis in [Observed Distributions](https://intro.quantecon.org/observed_distributions.html) to help judge whether a given data set looks normally distributed.\n",
    "\n",
    "The **cumulative distribution function** (CDF) of $ X $ is defined by\n",
    "\n",
    "$$\n",
    "F(x) = \\mathbb{P}\\{X \\leq x\\}\n",
    "        = \\sum_{i=1}^n \\mathbb 1\\{x_i \\leq x\\} p(x_i)\n",
    "$$\n",
    "\n",
    "Here $ \\mathbb 1\\{ \\textrm{statement} \\} = 1 $ if “statement” is true and zero otherwise.\n",
    "\n",
    "Hence the second term takes all $ x_i \\leq x $ and sums their probabilities."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1d7eef0",
   "metadata": {},
   "source": [
    "### Uniform distribution\n",
    "\n",
    "One simple example is the **uniform distribution**, where $ p(x_i) = 1/n $ for all $ i $.\n",
    "\n",
    "We can import the uniform distribution on $ S = \\{1, \\ldots, n\\} $  from SciPy like so:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1314d0b3",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "n = 10\n",
    "u = scipy.stats.randint(1, n+1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83995971",
   "metadata": {},
   "source": [
    "Here’s the mean and variance:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1067874b",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ced29046",
   "metadata": {},
   "source": [
    "The formula for the mean is $ (n+1)/2 $, and the formula for the variance is $ (n^2 - 1)/12 $.\n",
    "\n",
    "Now let’s evaluate the PMF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6f0caf9",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.pmf(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "067c94c7",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.pmf(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03e02613",
   "metadata": {},
   "source": [
    "Here’s a plot of the probability mass function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d3c127f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)\n",
    "ax.vlines(S, 0, u.pmf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('PMF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bff63027",
   "metadata": {},
   "source": [
    "Here’s a plot of the CDF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2453435f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "ax.step(S, u.cdf(S))\n",
    "ax.vlines(S, 0, u.cdf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11dd9764",
   "metadata": {},
   "source": [
    "The CDF jumps up by $ p(x_i) $ at $ x_i $."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f67d6b55",
   "metadata": {},
   "source": [
    "### Exercise 6.1\n",
    "\n",
    "Calculate the mean and variance for this parameterization (i.e., $ n=10 $)\n",
    "directly from the PMF, using the expressions given above.\n",
    "\n",
    "Check that your answers agree with `u.mean()` and `u.var()`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba8a3e04",
   "metadata": {},
   "source": [
    "### Bernoulli distribution\n",
    "\n",
    "Another useful distribution is the Bernoulli distribution on $ S = \\{0,1\\} $, which has PMF:\n",
    "\n",
    "$$\n",
    "p(i) = \\theta^i (1 - \\theta)^{1-i}\n",
    "\\qquad (i = 0, 1)\n",
    "$$\n",
    "\n",
    "Here $ \\theta \\in [0,1] $ is a parameter.\n",
    "\n",
    "We can think of this distribution as modeling probabilities for a random trial with success probability $ \\theta $.\n",
    "\n",
    "- $ p(1) = \\theta $ means that the trial succeeds (takes value 1) with probability $ \\theta $  \n",
    "- $ p(0) = 1 - \\theta $ means that the trial fails (takes value 0) with\n",
    "  probability $ 1-\\theta $  \n",
    "\n",
    "\n",
    "The formula for the mean is $ \\theta $, and the formula for the variance is $ \\theta(1-\\theta) $.\n",
    "\n",
    "We can import the Bernoulli distribution on $ S = \\{0,1\\} $ from SciPy like so:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dd1fae5a",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "θ = 0.4\n",
    "u = scipy.stats.bernoulli(θ)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "25b9c95c",
   "metadata": {},
   "source": [
    "Here’s the mean and variance at $ \\theta=0.4 $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3001ecf8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b03c349",
   "metadata": {},
   "source": [
    "We can evaluate the PMF as follows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fb4f94f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.pmf(0), u.pmf(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e07952f",
   "metadata": {},
   "source": [
    "### Binomial distribution\n",
    "\n",
    "Another useful (and more interesting) distribution is the **binomial distribution** on $ S=\\{0, \\ldots, n\\} $, which has PMF:\n",
    "\n",
    "$$\n",
    "p(i) = \\binom{n}{i} \\theta^i (1-\\theta)^{n-i}\n",
    "$$\n",
    "\n",
    "Again, $ \\theta \\in [0,1] $ is a parameter.\n",
    "\n",
    "The interpretation of $ p(i) $ is: the probability of $ i $ successes in $ n $ independent trials with success probability $ \\theta $.\n",
    "\n",
    "For example, if $ \\theta=0.5 $, then $ p(i) $ is the probability of $ i $ heads in $ n $ flips of a fair coin.\n",
    "\n",
    "The formula for the mean is $ n \\theta $ and the formula for the variance is $ n \\theta (1-\\theta) $.\n",
    "\n",
    "Let’s investigate an example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3cfa410c",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "n = 10\n",
    "θ = 0.5\n",
    "u = scipy.stats.binom(n, θ)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38d81f0b",
   "metadata": {},
   "source": [
    "According to our formulas, the mean and variance are"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "974fdaa8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "n * θ,  n *  θ * (1 - θ)  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11e4c33e",
   "metadata": {},
   "source": [
    "Let’s see if SciPy gives us the same results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "76a2e57e",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7075d374",
   "metadata": {},
   "source": [
    "Here’s the PMF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75d2d7db",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.pmf(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49b441d3",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)\n",
    "ax.vlines(S, 0, u.pmf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('PMF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "29c71020",
   "metadata": {},
   "source": [
    "Here’s the CDF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd6f3dee",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "ax.step(S, u.cdf(S))\n",
    "ax.vlines(S, 0, u.cdf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bfebd185",
   "metadata": {},
   "source": [
    "### Exercise 6.2\n",
    "\n",
    "Using `u.pmf`, check that our definition of the CDF given above calculates the same function as `u.cdf`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3e8809c",
   "metadata": {},
   "source": [
    "### Solution\n",
    "\n",
    "Here is one solution:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "22af2d05",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "u_sum = np.cumsum(u.pmf(S))\n",
    "ax.step(S, u_sum)\n",
    "ax.vlines(S, 0, u_sum, lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bfb0a9c",
   "metadata": {},
   "source": [
    "We can see that the output graph is the same as the one above."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e85e6c4e",
   "metadata": {},
   "source": [
    "### Geometric distribution\n",
    "\n",
    "The geometric distribution has infinite support $ S = \\{0, 1, 2, \\ldots\\} $ and its PMF is given by\n",
    "\n",
    "$$\n",
    "p(i) = (1 - \\theta)^i \\theta\n",
    "$$\n",
    "\n",
    "where $ \\theta \\in [0,1] $ is a parameter\n",
    "\n",
    "(A discrete distribution has infinite support if the set of points to which it assigns positive probability is infinite.)\n",
    "\n",
    "To understand the distribution, think of repeated independent random trials, each with success probability $ \\theta $.\n",
    "\n",
    "The interpretation of $ p(i) $ is: the probability there are $ i $ failures before the first success occurs.\n",
    "\n",
    "It can be shown that the mean of the distribution is $ 1/\\theta $ and the variance is $ (1-\\theta)/\\theta $.\n",
    "\n",
    "Here’s an example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "80162d99",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "θ = 0.1\n",
    "u = scipy.stats.geom(θ)\n",
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1f7b7d5",
   "metadata": {},
   "source": [
    "Here’s part of the PMF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f22d6f3",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "n = 20\n",
    "S = np.arange(n)\n",
    "ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)\n",
    "ax.vlines(S, 0, u.pmf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('PMF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1faeec5b",
   "metadata": {},
   "source": [
    "### Poisson distribution\n",
    "\n",
    "The Poisson distribution on $ S = \\{0, 1, \\ldots\\} $ with parameter $ \\lambda > 0 $ has PMF\n",
    "\n",
    "$$\n",
    "p(i) = \\frac{\\lambda^i}{i!} e^{-\\lambda}\n",
    "$$\n",
    "\n",
    "The interpretation of $ p(i) $ is: the probability of $ i $ events in a fixed time interval, where the events occur independently at a constant rate $ \\lambda $.\n",
    "\n",
    "It can be shown that the mean is $ \\lambda $ and the variance is also $ \\lambda $.\n",
    "\n",
    "Here’s an example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46938fd5",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "λ = 2\n",
    "u = scipy.stats.poisson(λ)\n",
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e945ed74",
   "metadata": {},
   "source": [
    "Here’s the PMF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7774db95",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.pmf(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "840d44b8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "S = np.arange(1, n+1)\n",
    "ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)\n",
    "ax.vlines(S, 0, u.pmf(S), lw=0.2)\n",
    "ax.set_xticks(S)\n",
    "ax.set_xlabel('S')\n",
    "ax.set_ylabel('PMF')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d07c94bc",
   "metadata": {},
   "source": [
    "## Continuous distributions\n",
    "\n",
    "A continuous distribution is represented by a **probability density function**, which is a function $ p $ over $ \\mathbb R $ (the set of all real numbers) such that $ p(x) \\geq 0 $ for all $ x $ and\n",
    "\n",
    "$$\n",
    "\\int_{-\\infty}^\\infty p(x) dx = 1\n",
    "$$\n",
    "\n",
    "We say that random variable $ X $ has distribution $ p $ if\n",
    "\n",
    "$$\n",
    "\\mathbb P\\{a < X < b\\} = \\int_a^b p(x) dx\n",
    "$$\n",
    "\n",
    "for all $ a \\leq b $.\n",
    "\n",
    "Expectations are defined as in the discrete case, after replacing the sum with an integral.\n",
    "\n",
    "For example, the mean of $ X $ is\n",
    "\n",
    "$$\n",
    "\\mathbb{E}[X] = \\int_{-\\infty}^\\infty x p(x) dx\n",
    "$$\n",
    "\n",
    "while, for a function $ f $,\n",
    "\n",
    "$$\n",
    "\\mathbb{E}[f(X)] = \\int_{-\\infty}^\\infty f(x) p(x) dx\n",
    "$$\n",
    "\n",
    "The variance, standard deviation, moments, skewness and kurtosis are then defined by exactly the same expressions as before.\n",
    "\n",
    "The **cumulative distribution function** (CDF) of $ X $ is defined by\n",
    "\n",
    "$$\n",
    "F(x) = \\mathbb P\\{X \\leq x\\}\n",
    "        = \\int_{-\\infty}^x p(x) dx\n",
    "$$\n",
    "\n",
    "For the continuous distributions we study below, $ F $ is strictly increasing, so it has an inverse $ F^{-1} $, which is called the **quantile function**.\n",
    "\n",
    "Given $ \\tau \\in (0,1) $, the value $ q_\\tau = F^{-1}(\\tau) $ is called the $ \\tau $-th **quantile** of the distribution.\n",
    "\n",
    "It is the point such that $ X $ falls below it with probability $ \\tau $.\n",
    "\n",
    "The 0.5 quantile is called the **median**, which is an alternative measure of the center of a distribution.\n",
    "\n",
    "The 0.25 and 0.75 quantiles are called the first and third **quartiles**, and the distance between them is the **interquartile range**, an alternative measure of spread.\n",
    "\n",
    "These alternatives are useful because, unlike the mean and the standard deviation, they are barely affected by a small number of extreme values.\n",
    "\n",
    "(We will see in [Heavy-Tailed Distributions](https://intro.quantecon.org/heavy_tails.html) that this robustness matters a great deal for some data sets.)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a12f1a50",
   "metadata": {},
   "source": [
    "### Normal distribution\n",
    "\n",
    "Perhaps the most famous distribution is the **normal distribution**, which has density\n",
    "\n",
    "$$\n",
    "p(x) = \\frac{1}{\\sqrt{2\\pi}\\sigma}\n",
    "            \\exp\\left(-\\frac{(x-\\mu)^2}{2\\sigma^2}\\right)\n",
    "$$\n",
    "\n",
    "This distribution has two parameters, $ \\mu \\in \\mathbb R $ and $ \\sigma \\in (0, \\infty) $.\n",
    "\n",
    "Using calculus, it can be shown that, for this distribution, the mean is $ \\mu $ and the variance is $ \\sigma^2 $.\n",
    "\n",
    "We can obtain the moments, PDF and CDF of the normal density via SciPy as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1f2adb8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "μ, σ = 0.0, 1.0\n",
    "u = scipy.stats.norm(μ, σ)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28de7f3a",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58220ef8",
   "metadata": {},
   "source": [
    "The `stats` method returns the skewness and excess kurtosis when we ask for moments `'sk'`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25c01b1c",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.stats(moments='sk')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f54f9733",
   "metadata": {},
   "source": [
    "Both are zero, as promised.\n",
    "\n",
    "(The skewness is zero because the density is symmetric about $ \\mu $.)\n",
    "\n",
    "Here are the median and the two quartiles, obtained via the `ppf` method (SciPy’s name for the quantile function):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "27b4da13",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.ppf(0.5), u.ppf(0.25), u.ppf(0.75)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a79c9712",
   "metadata": {},
   "source": [
    "The median equals the mean because the density is symmetric.\n",
    "\n",
    "Here’s a plot of the density — the famous “bell-shaped curve”:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64a9fdeb",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "μ_vals = [-1, 0, 1]\n",
    "σ_vals = [0.4, 1, 1.6]\n",
    "fig, ax = plt.subplots()\n",
    "x_grid = np.linspace(-4, 4, 200)\n",
    "\n",
    "for μ, σ in zip(μ_vals, σ_vals):\n",
    "    u = scipy.stats.norm(μ, σ)\n",
    "    ax.plot(x_grid, u.pdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\mu={μ}, \\sigma={σ}$')\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('PDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "858079c9",
   "metadata": {},
   "source": [
    "Here’s a plot of the CDF:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "41b5d0e5",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "for μ, σ in zip(μ_vals, σ_vals):\n",
    "    u = scipy.stats.norm(μ, σ)\n",
    "    ax.plot(x_grid, u.cdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\mu={μ}, \\sigma={σ}$')\n",
    "    ax.set_ylim(0, 1)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58e6993c",
   "metadata": {},
   "source": [
    "### Lognormal distribution\n",
    "\n",
    "The **lognormal distribution** is a distribution on $ \\left(0, \\infty\\right) $ with density\n",
    "\n",
    "$$\n",
    "p(x) = \\frac{1}{\\sigma x \\sqrt{2\\pi}}\n",
    "    \\exp \\left(- \\frac{\\left(\\log x - \\mu\\right)^2}{2 \\sigma^2} \\right)\n",
    "$$\n",
    "\n",
    "This distribution has two parameters, $ \\mu $ and $ \\sigma $.\n",
    "\n",
    "It can be shown that, for this distribution, the mean is $ \\exp\\left(\\mu + \\sigma^2/2\\right) $ and the variance is $ \\left[\\exp\\left(\\sigma^2\\right) - 1\\right] \\exp\\left(2\\mu + \\sigma^2\\right) $.\n",
    "\n",
    "It can be proved that\n",
    "\n",
    "- if $ X $ is lognormally distributed, then $ \\log X $ is normally distributed, and  \n",
    "- if $ X $ is normally distributed, then $ \\exp X $ is lognormally distributed.  \n",
    "\n",
    "\n",
    "We can obtain the moments, PDF, and CDF of the lognormal density as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f2b0d99",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "μ, σ = 0.0, 1.0\n",
    "u = scipy.stats.lognorm(s=σ, scale=np.exp(μ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9aca7bb9",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e59bb82d",
   "metadata": {},
   "source": [
    "The lognormal distribution provides a sharp contrast with the normal distribution in terms of higher moments:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf241df3",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.stats(moments='sk')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88542946",
   "metadata": {},
   "source": [
    "The skewness is large and positive, reflecting the long right tail, and the excess kurtosis is enormous.\n",
    "\n",
    "The gap between the mean and the median is correspondingly large:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0574d90",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.ppf(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bd4b8ccd",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "μ_vals = [-1, 0, 1]\n",
    "σ_vals = [0.25, 0.5, 1]\n",
    "x_grid = np.linspace(0, 3, 200)\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "for μ, σ in zip(μ_vals, σ_vals):\n",
    "    u = scipy.stats.lognorm(σ, scale=np.exp(μ))\n",
    "    ax.plot(x_grid, u.pdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=fr'$\\mu={μ}, \\sigma={σ}$')\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('PDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "070fb2a2",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "for μ, σ in zip(μ_vals, σ_vals):\n",
    "    u = scipy.stats.lognorm(σ, scale=np.exp(μ))\n",
    "    ax.plot(x_grid, u.cdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\mu={μ}, \\sigma={σ}$')\n",
    "    ax.set_ylim(0, 1)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a46b839",
   "metadata": {},
   "source": [
    "### Exponential distribution\n",
    "\n",
    "The **exponential distribution** is a distribution supported on $ \\left(0, \\infty\\right) $ with density\n",
    "\n",
    "$$\n",
    "p(x) = \\lambda \\exp \\left( - \\lambda x \\right)\n",
    "\\qquad (x > 0)\n",
    "$$\n",
    "\n",
    "This distribution has one parameter $ \\lambda $.\n",
    "\n",
    "The exponential distribution can be thought of as the continuous analog of the geometric distribution.\n",
    "\n",
    "It can be shown that, for this distribution, the mean is $ 1/\\lambda $ and the variance is $ 1/\\lambda^2 $.\n",
    "\n",
    "We can obtain the moments, PDF, and CDF of the exponential density as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "325aaffd",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "λ = 1.0\n",
    "u = scipy.stats.expon(scale=1/λ)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fbbd7613",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "872a6aeb",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "λ_vals = [0.5, 1, 2]\n",
    "x_grid = np.linspace(0, 6, 200)\n",
    "\n",
    "for λ in λ_vals:\n",
    "    u = scipy.stats.expon(scale=1/λ)\n",
    "    ax.plot(x_grid, u.pdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\lambda={λ}$')\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('PDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10e8f005",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "for λ in λ_vals:\n",
    "    u = scipy.stats.expon(scale=1/λ)\n",
    "    ax.plot(x_grid, u.cdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\lambda={λ}$')\n",
    "    ax.set_ylim(0, 1)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9901bbd7",
   "metadata": {},
   "source": [
    "### Beta distribution\n",
    "\n",
    "The **beta distribution** is a distribution on $ (0, 1) $ with density\n",
    "\n",
    "$$\n",
    "p(x) = \\frac{\\Gamma(\\alpha + \\beta)}{\\Gamma(\\alpha) \\Gamma(\\beta)}\n",
    "    x^{\\alpha - 1} (1 - x)^{\\beta - 1}\n",
    "$$\n",
    "\n",
    "where $ \\Gamma $ is the [gamma function](https://en.wikipedia.org/wiki/Gamma_function).\n",
    "\n",
    "(The role of the gamma function is just to normalize the density, so that it\n",
    "integrates to one.)\n",
    "\n",
    "This distribution has two parameters, $ \\alpha > 0 $ and $ \\beta > 0 $.\n",
    "\n",
    "It can be shown that, for this distribution, the mean is $ \\alpha / (\\alpha + \\beta) $ and\n",
    "the variance is $ \\alpha \\beta / (\\alpha + \\beta)^2 (\\alpha + \\beta + 1) $.\n",
    "\n",
    "We can obtain the moments, PDF, and CDF of the Beta density as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "815c9852",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "α, β = 3.0, 1.0\n",
    "u = scipy.stats.beta(α, β)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc441333",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58d92e33",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "α_vals = [0.5, 1, 5, 25, 3]\n",
    "β_vals = [3, 1, 10, 20, 0.5]\n",
    "x_grid = np.linspace(0, 1, 200)\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "for α, β in zip(α_vals, β_vals):\n",
    "    u = scipy.stats.beta(α, β)\n",
    "    ax.plot(x_grid, u.pdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\alpha={α}, \\beta={β}$')\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('PDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "168c333f",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "for α, β in zip(α_vals, β_vals):\n",
    "    u = scipy.stats.beta(α, β)\n",
    "    ax.plot(x_grid, u.cdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\alpha={α}, \\beta={β}$')\n",
    "    ax.set_ylim(0, 1)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38ba48d2",
   "metadata": {},
   "source": [
    "### Gamma distribution\n",
    "\n",
    "The **gamma distribution** is a distribution on $ \\left(0, \\infty\\right) $ with density\n",
    "\n",
    "$$\n",
    "p(x) = \\frac{\\beta^\\alpha}{\\Gamma(\\alpha)}\n",
    "    x^{\\alpha - 1} \\exp(-\\beta x)\n",
    "$$\n",
    "\n",
    "This distribution has two parameters, $ \\alpha > 0 $ and $ \\beta > 0 $.\n",
    "\n",
    "It can be shown that, for this distribution, the mean is $ \\alpha / \\beta $ and\n",
    "the variance is $ \\alpha / \\beta^2 $.\n",
    "\n",
    "One interpretation is that if $ X $ is gamma distributed and $ \\alpha $ is an\n",
    "integer, then $ X $ is the sum of $ \\alpha $ independent exponentially distributed\n",
    "random variables with mean $ 1/\\beta $.\n",
    "\n",
    "We can obtain the moments, PDF, and CDF of the Gamma density as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "82ec8230",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "α, β = 3.0, 2.0\n",
    "u = scipy.stats.gamma(α, scale=1/β)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c09df914",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "u.mean(), u.var()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f239505",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "α_vals = [1, 3, 5, 10]\n",
    "β_vals = [3, 5, 3, 3]\n",
    "x_grid = np.linspace(0, 7, 200)\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "for α, β in zip(α_vals, β_vals):\n",
    "    u = scipy.stats.gamma(α, scale=1/β)\n",
    "    ax.plot(x_grid, u.pdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\alpha={α}, \\beta={β}$')\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('PDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d165bac2",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "for α, β in zip(α_vals, β_vals):\n",
    "    u = scipy.stats.gamma(α, scale=1/β)\n",
    "    ax.plot(x_grid, u.cdf(x_grid),\n",
    "    alpha=0.5, lw=2,\n",
    "    label=rf'$\\alpha={α}, \\beta={β}$')\n",
    "    ax.set_ylim(0, 1)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('CDF')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "date": 1795846200.5314515,
  "filename": "prob_dist.md",
  "kernelspec": {
   "display_name": "Python",
   "language": "python3",
   "name": "python3"
  },
  "title": "Probability Distributions"
 },
 "nbformat": 4,
 "nbformat_minor": 5
}