{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"from datascience import *\n",
"from prob140 import *\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('fivethirtyeight')\n",
"%matplotlib inline\n",
"from scipy import stats"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"def plot_prior_and_posterior(r, s, n, k):\n",
" p = np.arange(0, 1, 0.01)\n",
" prior = stats.beta.pdf(p, r, s)\n",
" posterior = stats.beta.pdf(p, r+k, s+n-k)\n",
" plt.plot(p, prior, lw=2, color='gold', label = 'Prior: beta (r, s)')\n",
" plt.plot(p, posterior, lw=2, color='darkblue', label = 'Posterior: beta(r+k, s+n-k)')\n",
" plt.legend(bbox_to_anchor=(1.6, 1.02))\n",
" ymax = max(max(prior), max(posterior))\n",
" plt.ylim(-0.3, ymax+0.1)\n",
" plt.xlim(0, 1)\n",
" plt.scatter(r/(r+s), -0.1, marker='^', s=40, color='gold')\n",
" plt.scatter((r+k)/(r+s+n), -0.1, marker='^', s=40, color='darkblue')\n",
" plt.scatter(k/n, -0.02, s=30, color='red')\n",
" plt.xlabel('$p$')\n",
" plt.title('Prior, and Posterior Given $S_n = k$ (red dot at $k/n$)');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Updating and Prediction ##"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let $X$ be a random variable with a beta density. Given $X=p$, toss a $p$-coin $n$ times and observe the number of heads. Based on the number of heads, we are going to:\n",
"- Identify the posterior distribution of $X$ \n",
"- Predict the chance of heads on the $(n+1)$st toss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Beta Prior ###\n",
"For positive integers $r$ and $s$, we derived the beta $(r, s)$ density\n",
"\n",
"$$\n",
"f(x) = \\frac{(r+s-1)!}{(r-1)!(s-1)!} x^{r-1}(1-x)^{s-1}, ~~~ 0 < x < 1\n",
"$$\n",
"\n",
"by studying order statistics of i.i.d. uniform $(0, 1)$ random variables. The beta family can be extended to include parameters $r$ and $s$ that are positive but not integers. This is possible because of two facts that you have observed in exercises:\n",
"- The Gamma function is a continuous extension of the factorial function.\n",
"- If $r$ is a positive integer then $\\Gamma(r) = (r-1)!$.\n",
"\n",
"For fixed positive numbers $r$ and $s$, not necessarily integers, the beta $(r, s)$ density is defined by\n",
"\n",
"$$\n",
"f(x) = \n",
"\\frac{\\Gamma(r+s)}{\\Gamma(r)\\Gamma(s)} x^{r-1}(1-x)^{s-1}, ~~~ 0 < x < 1 \n",
"$$\n",
"\n",
"We will not prove that this function integrates to 1, but it is true and should be believable because we have seen it to be true for integer values of the parameters.\n",
"\n",
"To simplify notation, we will denote the constant in the beta $(r, s)$ density by $C(r, s)$.\n",
"\n",
"$$\n",
"C(r, s) ~ = ~ \\frac{\\Gamma(r+s)}{\\Gamma(r)\\Gamma(s)}\n",
"$$\n",
"\n",
"so that the beta $(r, s)$ density is given by $C(r, s)x^{r-1}(1-x)^{s-1}$ for $x \\in (0, 1)$.\n",
"\n",
"Beta distributions are often used to model random proportions. In the previous chapter you saw the beta $(1, 1)$ distribution, better known as the uniform, used in this way to model a randomly picked coin.\n",
"\n",
"You also saw that given that we know the value of $p$ for the coin we are tossing, the tosses are independent, but when we don't know $p$ then the tosses are no longer independent. For example, knowledge of how the first toss came out tells us something about $p$, which in turn affects the probabilities of how the second toss might come out. \n",
"\n",
"We will now extend these results by starting with a general beta $(r, s)$ prior for the chance that the coin lands heads."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The Experiment ###\n",
"Let $X$ have the beta $(r, s)$ distribution. This is the prior distribution of $X$. Denote the prior density by $f_X$. Then\n",
"\n",
"$$\n",
"f_X(p) ~ = ~ C(r, s)p^{r-1}(1-p)^{s-1}, ~~~~ 0 < p < 1\n",
"$$\n",
"\n",
"Given $X = p$, let $I_1, I_2, \\ldots$ be i.i.d. Bernoulli $(p)$. That is, given $X = p$, toss a $p$-coin repeatedly and record the results as $I_1, I_2, \\ldots$.\n",
"\n",
"Let $S_n = I_1 + I_2 + \\cdots + I_n$ be the number of heads in the first $n$ tosses. Then the conditional distribution of $S_n$ given $X = p$ is binomial $(n, p)$. It gives you the likelihood of the observed number of heads given a value of $p$."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"remove-input",
"hide-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" VIDEO"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# VIDEO: Conjugate Priors\n",
"from IPython.display import YouTubeVideo\n",
"\n",
"YouTubeVideo('NBySphqHwvw')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Updating: The Posterior Distribution of $X$ Given $S_n$ ###\n",
"Before running the experiment, our prior opinion is that $X$ has the beta $(r, s)$ distribution. To update that opinion after we have tossed $n$ times and seen the number of heads, we have to find the posterior distribution of $X$ given $S_n = k$.\n",
"\n",
"As we have seen, the posterior density is proportional to the prior times the likelihood. For $0 < p < 1$,\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"f_{X \\vert S_n=k} (p) ~ &\\propto ~ {C(r, s) p^{r-1}(1-p)^{s-1} \\cdot \\binom{n}{k} p^k (1-p)^{n-k}}\\\\ \\\\\n",
"&\\propto ~ p^{r+k-1}(1-p)^{s + (n-k) - 1} \n",
"\\end{align*}\n",
"$$\n",
"\n",
"because $C(r, s)$ and $\\binom{n}{k}$ do not involve $p$.\n",
"\n",
"You can see at once that this is the beta $(r+k, s+n-k)$ density:\n",
"\n",
"$$\n",
"f_{X \\mid S_n = k} (p) ~ = ~ C(r+k, s+n-k) p^{r+k-1}(1-p)^{s + n - k - 1}, ~~~ 0 < p < 1\n",
"$$\n",
"\n",
"This beta posterior density is easy to remember. Start with the prior; update the first parameter by adding the observed number of heads; update the second parameter by adding the observed number of tails.\n",
"\n",
"### Conjugate Prior ###\n",
"The prior distribution of the probability of heads is from the beta family. The posterior distribution of the probability of heads, given the number of heads, is another beta density. The beta prior and binomial likelihood combine to result in a beta posterior. The beta family is therefore called a *family of conjugate priors* for the binomial distribution: the posterior is another member of the same family as the prior."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MAP Estimate: Posterior Mode ###\n",
"The MAP estimate of the chance of heads is the mode of the posterior distribution. If $r$ and $s$ are both greater than 1 then the mode of the posterior distribution of $X$ is\n",
"\n",
"$$\n",
"\\frac{r+k-1}{r+s+n-2}\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"tags": [
"remove-input",
"hide-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" VIDEO"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# VIDEO: Prediction\n",
"\n",
"YouTubeVideo('h7FmqsTfSKY')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Posterior Mean ###\n",
"The posterior mean of $X$ given $S_n = k$ is the expectation of the beta posterior distribution, which for large $n$ is not far from the mode:\n",
"\n",
"$$\n",
"E(X \\mid S_n = k) ~ = ~ \\frac{r+k}{r+s+n} \n",
"$$\n",
"\n",
"Let's examine this result in an example. Suppose the prior distribution of $X$ is beta $(5, 3)$, and thus the prior mean is $E(X) = 5/8 = 0.625$. Now suppose we are given that $S_{100} = 70$. Then the posterior distribution of $X$ given $S_{100} = 70$ is beta $(75, 33)$ with mean $75/108 = 0.694$.\n",
"\n",
"The graph below shows the two densities along with the corresponding means. The red dot is at the observed proportion of heads. \n",
"\n",
"Run the cell again, keeping $r = 5$ and $s = 3$ but changing $n$ to 10 and $k$ to 7, then again changing $n$ to 1000 and $k$ to $700$. The observed proportion is 0.7 in all cases. Notice how increasing the sample size concentrates the prior around 0.7. We will soon see the reason for this. \n",
"\n",
"Also try other values of the parameters as well as $n$ and $k$, including values where the observed proportion is quite different from the mean of the prior."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAEaCAYAAACsBgtkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xec0/X9B/DXJzu5vY89j3EsOYYgGxQVpThwr6pVqb9atf6sLdrW1bqLws9ZRK221oHWqlhAZIigIkMETjjgjsNjHbdyl1zGN9/P749vAke4kdxK7vJ6Ph55QJLveOeTby7vfKaQUoKIiIiIopcu0gEQERERUeOYsBERERFFOSZsRERERFGOCRsRERFRlGPCRkRERBTlmLARERERRTkmbERERERRjgkbERERUZTr8AmbEOJ1IcTnkY6jNQghHhRC7I10HK0tWt6jaIkj2ggh7hVCbA9zn3ghRIkQYkwbxdSsz0JH+gw1p9xDPO7LQoinW/u4RBRZUZOw+b9Mpf+mCCEOCCFeEkKkNbHrnQAua48Yo0ELyimcc3wuhHi9tY6HNn6PhBCpQojHhBC7hBBOIUSFEGKbEOLPQoge7RVHcwgh0oUQT9SJvVwIsUkIcV07hpEHYGuY+9wH4Dsp5aY2iKddteb1HuaxQip3IcRDQogPwgjjYQC/FEL0DWMfIopyUZOw+X0JoAuA3gB+DeBSAH+vb0MhhAkApJRVUsqKlpw0cKwOJORyiqT2eI/8CdlWAJcDeAzAOABnAvg9gDQA/xvYtjXiaE1CiCxosY8FcAeAXAAzAbwHQG3HUPIAbAl1YyGEBcAvAbzcxHYd7XPV3kIt94sBfBjqQaWUJQBWAbi9mXERUTSSUkbFDcDrAD4Peux+AD4AVgBrALwK4BEAhwGU1rcfACOAxwGUAPAA2AXg6qDj1nusEOM8x79/OYAqAGsBjK3n+IsB/AHAEf+2rwOIq7ONGcCL/mNU+P//GIC9LSynUF7/RABfAaj2374HcG6d48ug21T/c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JTjrrGxUVrrx/POtuaIWUbPw+446ggavU17ARNQq/vKXzTh2rBaTJ3fFihU/Q58+ifjDH8YAAF544QccPx68TjpRbElNTR01ZsyY3Ly8vCFz587tW1NTU+938KxZs/qXlZXpW+Oc1113Xe+33norJdTtCwoKTEuWLEkN9zwOh0NMmzZtoKK0fKGgZ555JuPFF19Ma/GBOhkmbETUYm63D6tXlwAAnn9+CpKTzQCA8eOzcc45PVBT48WCBd9HMkSiiDObzeqmTZt2bdmyZafRaJSLFi3KqPu8qqrw+XxYtmzZ3rS0tJCWFgvs01r2799v/uCDD8JO2F5++eX0888/v8JgOLVrfHMSuNtuu63stddeywp7x06OCRsRtdjGjUdQU+NFbm4qevSIP+W5++8fDQBYvHgXSkpqIhEeUdQZN25cTWFhobmgoMA0YsSIIbfeemvPcePG5RYWFpoGDRo07MiRIwYAeOyxx7Ly8vKG5OXlDXniiScyAa0WLHifxs61Zs2ahClTpgwcNmzY0Pfffz8J0BKpu+66q/v48eMHjxo1KnfhwoXpAPDwww9327p1a/yYMWNyH3/88cyCggLTlClTBo4dO3bw2LFjB69evTquvnN8+OGHaRdffHElACxfvjxhxowZA6688so+o0ePHtJYbPfcc0+3M844Y8ioUaNy77zzzu4AEB8fr3bt2tX95Zdf2sIt186Mo0SJqMWWLy8GAJx7bo/TnjvjjHTMmdMHH31UiKef3ooFCya1d3hEp0k6nDyqNY9X1aVyc6jber1erFq1KnH69Ol2ACguLrYsXLiw6JVXXimuu92GDRts7733XtratWvzpZSYMmXK4KlTp1anpqb6gve58cYbe/3iF78onTBhgjP4fCUlJeYvvvhi9+7du81z5swZOGvWrB9effXVtMTERN/GjRvza2trxbRp0wadd9559j/+8Y8lixYtyvrkk0/2AkBNTY3us88+22Oz2eSuXbvMN910U9+vv/46v+7xXS6XKCkpMefk5JwYXbRz5864devW7RwwYECDI45KS0v1K1euTNm2bdsOnU6Hus3AI0aMcHz55ZcJkyZNOu31xCombETUYoGEbebMnvU+P3/+KHz0USHeeWcvnnpqA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jl45MiRQxYtWnSiX8V7772XOnv27EpAS8pGjBgx5NZbb+05bty43MLCwrD+2Nx3331dr7vuut51E71gb775ZkpeXt6Q0aNH506dOjXkBLBLly4j77333m6jR4/OnTBhwqCSkpJG5zM5cuSIYeLEiYOWLl2aBAAXXHBB5b/+9a+wEsEmJ0wRQnQD8GsAuVLKWiHEuwCuBPB6OCcios4j0P8s3OZQgBPoUnRITv7baYuYt0Rl5S0hLybv9XqxatWqxOnTp9s3bNhge++999LWrl2bL6XElClTBk+dOrV679695qysLO+nn366FwDKy8v1qampvldffTVr2bJle7Kzs5UjR44YnnnmmS6fffbZnoSEBPXhhx/OfvLJJ7MeffTRw4BWo7d27drdALBq1aokAHA6neKuu+7q88EHH+weOnSo+5prrum9cOHCjPvuu+9Y8D7PPfdcBgDceeedpcGvYefOnXEbN27cGRcXp06aNCl31qxZVfHx8epHH32UumbNmh9NJpO89dZbey5ZsiTtmWeeKfnnP/+ZWXfh+8WLFxdlZGT4HA6HmDRpUu4VV1xRkZmZ6du6dWv8Sy+9dCCwXXFxsWXhwoVFr7zySnE478fdd9/d3W636994440ina7huqkFCxZ0+fDDD/f06tXLW1ZWpm9wwyC1tbW6sWPH1jz11FMld999d/eXX3454+GHHz5c37YlJSWGyy67rP/8+fMPXXjhhXYAGDdunOOJJ57oGs5rCnWGOwMAqxDCC8AG4FA4JyGizmXHDq3/2tChqWHvG5hAd/36w9i06RhmzerV2uERRaVALRMAjB49unrevHnHFy5cmDFz5szKhIQEFQBmzpxZsW7duoTzzz+/6tFHH+3xm9/8ptusWbOqzj777Jrg461fvz6usLDQMn369EEA4PV6xRlnnHFiu6uuuqoieJ+dO3daunbt6h46dKgbAK655pqyv/3tb5kAjgXvU1+iFjBu3Dh7ZmamLxDz+vXr4w0Gg9y1a5dtwoQJgwOvN3j90IAFCxZkrVixIhkAjh49aszPz7dkZmY67Ha7ITk5+URzaHZ2tmfKlCmOwP2LLrqoX0lJidnr9YqjR4+aAuV50003Hf3lL39ZBgDPP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kZyDWdmZkc8j7CZpdMLrJ2w3A0MuVkzM7MsuGEzq0HSXJJp0NcmPLwceDCfRGZm1mzcsJnV1gvsBS6TVJb0ceCLwI25pjIzs6ZRzjuA2QzQC6wGzgYGgX7gkxGxOddUZmbWNNywmdXWCzwVEbfmHcTMzJqTp0TNausFns07hJmZNS83bGa1nQFsyTuEmZk1L5+HzczMzKzgPMJmZmZmVnBu2MzMzMwKzg2bmZmZWcG5YTMzMzMrODdsZmZmZgXnhs3MzMys4NywmZmZmRWcGzYzMzOzgvsfwJ4sZEUzd4YAAAAASUVORK5CYII=\n",
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Prior: beta (r, s)\n",
"# Given: S_n = k\n",
"\n",
"# Change the values\n",
"r = 5\n",
"s = 3\n",
"n = 100\n",
"k = 70\n",
"\n",
"# Leave this line alone\n",
"plot_prior_and_posterior(r, s, n, k)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can see how the data dominate the prior. The posterior distribution is concentrated around the posterior mean. The prior mean was 0.625, but given that we got 70 heads in 100 tosses, the posterior mean is 0.694 which is very close to the observerd proportion 0.7. \n",
"\n",
"The formula for the posterior mean shows that for large $n$ it is likely to be close to the observed proportion of heads. Given $S_n = k$, the posterior mean is\n",
"\n",
"$$\n",
"E(X \\mid S_n = k) ~ = ~ \\frac{r + k}{r + s + n}\n",
"$$\n",
"\n",
"Therefore as a random variable, the posterior mean is\n",
"\n",
"$$\n",
"E(X \\mid S_n) ~ = ~ \\frac{r + S_n}{r + s + n}\n",
"$$\n",
"\n",
"As the number of tosses $n$ gets large, the number of heads $S_n$ is likely to get large too. So the value of $S_n$ is likely to dominate the numerator, and $n$ will dominate the denominator, because $r$ and $s$ are constants. Thus for large $n$, the posterior mean is likely to be close to $S_n/n$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Prediction: The Distribution of $S_{n+1}$ Given $S_n$ ###\n",
"As you saw in the previous chapter, the chance that a random coin lands heads is the expected value of its random probability of heads. Apply this to our current setting to see that\n",
"\n",
"$$\n",
"P(S_1 = 1) ~ = ~ P(\\text{first toss is a head}) ~ = ~ E(X) ~ = ~ \\frac{r}{r+s}\n",
"$$\n",
"\n",
"Now suppose that we have the results of the first $n$ tosses, and that $k$ of those tosses were heads. Given that $S_n = k$, the possible values of $S_{n+1}$ are $k$ and $k+1$. We can now use our updated distribution of $X$ and the same reasoning as above to see that\n",
"\n",
"$$\n",
"P(S_{n+1} = k+1 \\mid S_n = k) ~ = ~ P(\\text{toss } n+1 \\text{ is a head} \\mid S_n = k)\n",
"~ = ~ E(X \\mid S_n = k) ~ = ~ \\frac{r+k}{r + s + n}\n",
"$$\n",
"\n",
"We can work out $P(S_{n+1} = k \\mid S_n = k)$ by the complement rule. We now have a transition function. Given that $S_n = k$, the conditional distribution of $S_{n+1}$ is given by\n",
"\n",
"$$\n",
"S_{n+1} =\n",
"\\begin{cases} \n",
"k ~~~~~~~~ \\text{ with probability } (s + n - k)/(r + s + n) \\\\\n",
"k+1 ~~ \\text{ with probability } (r+k)/(r + s + n)\n",
"\\end{cases}\n",
"$$\n",
"\n",
"In other words, given the results of the first $n$ tosses, the chance that Toss $n+1$ is a tail is proportional to $s$ plus the number of failures. The chance that Toss $n+1$ is a head is proportional to $r$ plus the number of successes.\n",
"\n",
"You can think of the sequence $\\{ S_n: n \\ge 1 \\}$ as a Markov chain, but keep in mind that the transition probabilities are not time-homogenous – the formulas involve $n$. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"celltoolbar": "Tags",
"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.8.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}