{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Definition ##"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define the *deviation from the mean* to be $X - \\mu_X$. Let's see what we expect that to be. By the linear function rule,\n",
"\n",
"$$\n",
"E(X - \\mu_X) = E(X) - \\mu_X = \\mu_X - \\mu_X = 0\n",
"$$\n",
"\n",
"For every random variable, the expected deviation from the mean is 0. The positive deviations exactly cancel out the negative ones.\n",
"\n",
"This cancellation prevents us from understanding how big the deviations are regardless of their sign. But that's what we need to measure, if we want to measure the distance between the random variable $X$ and its expectation $\\mu_X$.\n",
"\n",
"We have to get rid of the sign of the deviation somehow. One time-honored way of getting rid of the sign of a number is to take the absolute value. The other is to square the number. That's the method we will use. As you will see, it results in a measure of spread that is crucial for understanding the sums and averages of large samples.\n",
"\n",
"Measuring the rough size of the squared deviations has the advantage that it avoids cancellation between positive and negative errors. The disadvantage is that squared deviations have units that are difficult to understand. The measure of spread that we are about to define takes care of this problem."
]
},
{
"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: Standard deviation\n",
"from IPython.display import YouTubeVideo\n",
"\n",
"YouTubeVideo('9h34zgXmuqo')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Standard Deviation ###\n",
"\n",
"Let $X$ be a random variable with expectation $\\mu_X$. The *standard deviation* of $X$, denoted $SD(X)$ or $\\sigma_X$, is the *root mean square (rms) of deviations from the mean*:\n",
"\n",
"$$\n",
"SD(X) = \\sigma_X = \\sqrt{ E\\big{(} (X-\\mu_X)^2 \\big{)} }\n",
"$$\n",
"\n",
"$SD(X)$ has the same units as $X$ and $E(X)$. In this chapter we will make precise the sense in which the standard deviation measures the spread of the distribution of $X$ about the center $\\mu_X$.\n",
"\n",
"The quantity inside the square root is called the *variance* of $X$ and has better computational properties than the SD. This turns out to be closely connected to the fact that by Pythagoras' Theorem, squares of distances combine in useful ways.\n",
"\n",
"$$\n",
"Var(X) = \\sigma_X^2 = E\\big{(} (X-\\mu_X)^2 \\big{)}\n",
"$$\n",
"\n",
"Almost invariably, we will calculate standard deviations by first finding the variance and then taking the square root.\n",
"\n",
"Let's try out the definition of the SD on a random variable $X$ that has the distribution defined below."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"Value Probability 3 0.2 4 0.5 5 0.3

"
],
"text/plain": [
"Value | Probability\n",
"3 | 0.2\n",
"4 | 0.5\n",
"5 | 0.3"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = make_array(3, 4, 5)\n",
"probs = make_array(0.2, 0.5, 0.3)\n",
"dist_X = Table().values(x).probability(probs)\n",
"dist_X"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4.1"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dist_X.ev()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here are the squared deviations from the expectation $E(X) = 4.1$."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"x (x - 4.1)**2 P(X = x) 3 1.21 0.2 4 0.01 0.5 5 0.81 0.3

"
],
"text/plain": [
"x | (x - 4.1)**2 | P(X = x)\n",
"3 | 1.21 | 0.2\n",
"4 | 0.01 | 0.5\n",
"5 | 0.81 | 0.3"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sd_table = Table().with_columns(\n",
" 'x', dist_X.column(0),\n",
" '(x - 4.1)**2', (dist_X.column(0)-4.1)**2,\n",
" 'P(X = x)', dist_X.column(1)\n",
")\n",
"sd_table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The standard deviation of $X$ is the square root of the mean squared deviation. The calculation below shows that its numerical value is $SD(X) = 0.7$."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.7"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sd_X = np.sqrt(sum(sd_table.column(1)*sd_table.column(2)))\n",
"sd_X"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `prob140` method `sd` applied to a distribution object returns the standard deviation, saving you the calculation above."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.7"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dist_X.sd()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"The random variable $X$ has distribution given by $P(X = -2) = 0.3$, $P(X = 2) = 0.5$, and $P(X = 3) = 0.2$.\n",
"\n",
"(a) Find $E(X)$.\n",
"\n",
"(b) Apply the definition of standard deviation to find $SD(X)$.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"(a) $1$\n",
"\n",
"(b) $2$\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now know how to calculate the SD. But we don't yet have a good understanding of what it does. Let's start developing a few properties that it ought to have. Then we can check if it has them.\n",
"\n",
"First, the SD of a constant should be 0. You should check that this is indeed what the definition implies."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Shifting and Scaling ###\n",
"The SD is a measure of spread. It's natural to want measures of spread to remain unchanged if we just shift a probability histogram to the left or right. Such a shift occurs when we add a constant to a random variable. The figure below shows the distribution of the same $X$ as above, along with the distribution of $X+5$. It is clear that $X+5$ should have the same SD as $X$."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfgAAAEGCAYAAACJsIcWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAZvklEQVR4nO3de5SddX3v8fc3t5kwKCEQYkxyRGTAoDleuByQc7whFlqOsLrqnTRHaT3USkV7DkGlaIsisrqoXZSjtJgSRVGO2pKFXRoEqaUqcBJRwaCbApJgSAJkYhyTSSDf88d+YqdjLs/MPPsyz7xfa83a+/ntvX/Pd/Z6Zn3m99x+kZlIkqR6mdLpAiRJUvUMeEmSasiAlySphgx4SZJqyICXJKmGpnW6gP3ZunWrp/hLUs0dcsgh0eka6sgRvCRJNWTAS5JUQ7UP+Eaj0ekSJhS/r9HzOxs9v7PR8zvTaNU+4CVJmowMeEmSaqirz6KXJGmsVq9ePaW3t/ei6dOnL6KeA9rdu3btWrtjx44rjz/++N0jXzTgJUm11Nvbe9GcOXPe1NPT8xvhVxdDQ0OLN2/eDHDFyNfaFvAR8QiwDXgGeDozT4iI2cCXgCOBR4A3ZeaWdtUkSaqv6dOnL6pzuAP09PTsLvZQ/IZ277J4TWa+NDNPKJYvBm7LzH7gtmJZkq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Je6RERkRBzd6Tok1YMBL1UoIr4REX+xl/azI+LxYpIVSWo5A16q1vXAkuJObcMtoXnb5KfbX5KkyciAl6r1j8Bs4L/taSgmWTkLWBkR342IgYjYEBF/U9wB7zdExB0R8QfDlv9HRNw5bPmFEXFrRDwVET+JiDe17leSNBEZ8FKFMnM7cBPw+8Oa3wQ8APwSeB9wOHAKzXuxv3u06yimpL0V+ALNaUPfCvyfiHjRuIqXVCsGvFS9FcAbI2Jmsfz7wIrMXJ2Z38vMpzPzEeBa4FVj6P8s4JHM/PuirzU0Z078vSqKl1QPnvAjVSwz74yIzcDZEXE3cCLwuxFxDHAVcAJwEM2/v9VjWMXzgP8SEQPD2qYBnxtf5ZLqxICXWuOzNEfuxwKrMnNjRHyB5gxqb83MbRFxIfsedQ/S/Cdgj+cMe74O+OfMPL0FdUuqCXfRS63xWeB1wB/S3GUP8CzgF8AvI+KFwB/t5/P30hz1H1RcG3/esNduAY6JiCURMb34OTEiFlX/a0iaqAx4qQWKY+zfAfqAlUXz/wLeBmwD/g740n66+CtgJ7CR5j8Inx/W9zbg9cBbgJ8DjwOfAHqq/B0kTWzOBy9JUg05gpckqYYMeEmSasiAlySphgx4SZJqyICXJKmGDHhJkmrIgJckqYYMeEmSasiAlySphv4/WQAnljo3mlIAAAAASUVORK5CYII=\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"dist2 = Table().values(x+5).probability(probs)\n",
"Plots('X', dist_X, 'X+5', dist2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On the other hand, multiplying $X$ by a constant results in a distribution that should have a different spread. Here is the distribution of $X$ along with the distribution of $4X$. The spread of the distribution of $4X$ appears to be four times as large as that of $X$. "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfAAAAEGCAYAAACaZ8fiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzA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vX6bSvgmflwcbslIr4PHAtsjoh5mbkpIuYBW9qVR5KkVps6dWp+8pOf3Lhs2bK+q666qtbT09O0zd5t2QceEb0R8cLd94E3A/cA1wLLitmWAde0I48kSe1y/fXXz5g9e/bOe+65p6n76Np1ENtc4OaIuBO4DfhBZv6Q+ti2JRFRA5Ywylg3SZKq6Lbbbpv+05/+9IDrr79+3apVq+Zu2LBhSrOW3ZZN6Jm5HnjlCO2PAie0I4MkSe20a9cuPvaxjx1y4YUXbjj88MN3vP/979989tlnL/jGN77xQDOW3+lhZJIk7ZVWrFhx0Lx583YsXbr0DwBnnnnmlvXr1/dcf/31+zdj+Z5KVZK0T1iwoHfH+ecf19TljfX4Rz7ykUc+8pGPPLJ7er/99uPWW2+9r1mvbwGXJO0T5s+fvrnRsK8qcRO6JEkVZAGXJKmCLOCSJFWQBVySpAqygEuSVEEWcEmSWuzpp5/m2GOPffnSpUuPADj55JOPuPLKK2ftfvz0008/5KKLLpo7nmU6jEyStE+YFg/NnbRrY9MuJ7pr0oIdgzl/zMuJ7vbZz3527mGHHfbUk08+ORng0ksv/d3JJ5/80re//e1P3HXXXT133nln7xVXXDGuK5VZwCVJ+4RJuzZOnfTYRU27nCizzoeY33C2Bx54YMqaNWtmfPzjH9+0YsWKuQB9fX073vWud239xCc+seDuu+/uvfjii383derUcV2pzE3okiS10FlnnbXw05/+9MZJk55bcs8777zNN9988wFHHHHEU0uWLHlyvMu1gEuS1CLf+c53ZsyePfvp1772tX8c/tjPf/7z6UCsX7++55lnnhn3si3gkiS1yC233LL/j3/845kve9nLFn/wgx887Pbbb3/he97znpc888wznHXWWS++7LLLHjjkkEMGv/jFL84Z77It4JIktcill176UK1Wu2vdunV3X3755euPOeaYbVdfffUDl1122ZxDDz108MQTT9z2uc99bsPKlStftGnTpnEdl2YBlySpjR5++OH9rrjiihddcsklGwBe/OIX73zf+963Zfny5QvGsxyPQpck7RN2TVqwg1nnN3d54zhu/MQTT9x24oknbgNYt27d3UMfO/fcc0sNRx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7nkFQNFnCpiSLiRxHx6RHaT4mI30dE1557QVK1WMCl5voKcFpxprKhTqN+ytGn2x9J0t7IAi411z8Bs4D/tLuhuDLUUuDaiLglIvojYlNE/GNxmuDniYibIuIvh0y/LyJuHjL9soi4ISIei4hfR8Q7W/eWJHUjC7jURJn5FPBt4L8NaX4n9XNtPwn8HXAQ8BrgBOBD432N4vz6NwBXU7/84qnA/4qIP92j8JIqxQIuNd9q4B3FxSagXsxXZ+YdmfmzzHw6Mx8EVgKvm8DylwIPZub/KZa1lvpVwf6iGeElVYMH1EhNlpk3R8RW4JSIuA04Bnh7RBwJfB44GngB9d+/iVwf+RDgP0RE/5C2/YCv7VlySVViAZda46vU17xfClyfmZsj4mrgF8CpmbktIs5k9LXmAepFfrcXDbm/AfjnzFzSgtySKsJN6FJrfJX6tZr/ivomdYAXAn8AnoyIlwEfHOP5v6S+1v6CYmz4GUMeuw44MiJOi4gpxc8xEbGo+W9DUreygEstUOzj/inQC1xbNJ8FvAfYBlwJfGuMRfxPYAewmfo/AF8fsuxtwJuBdwMPA78HPgNMa+Z7kNTdvB64JEkV5Bq4JEkVZAGXJKmCLOCSJFWQBVySpAqygEuSVEEWcEmSKsgCLklSBVnAJUmqIAu4JEkV9P8Bq5VzDoZt+xsAAAAASUVORK5CYII=\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"dist3 = Table().values(4*x).probability(probs)\n",
"Plots('X', dist_X, '4X', dist3 )\n",
"plt.xlim(0, 40);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Multiplying by $-4$ should have the same effect on the spread as multiplying by 4, as the figure below shows. One histogram is just the mirror image of the other about the vertical axis at 0. There is no change in spread."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAEGCAYAAACTjGeYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB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xvQaN++69Ztn3DllXdNHKnlXX75y5k9e1JD77nmmmuOeOMb3/jkfffd113fvnDhwo2veMUr5n3iE584YsWKFYctXrz4543maVmXe2Y+VrxuBL4KnARsiIhZAMXrxlblkSSplR599NHxX//616d+8IMffFY3y4QJE/KjH/3ouo9//ONzFy1atLarq6vh7vOWFPSI6I6I5+4bBl4PPAjcBpxTzHYOcGsr8kiS1GoXXnjh3CuuuGLduHEDd44vW7Zs8vTp03c/+OCDwzpm0qou95nAVyNi3zpvzsyvR8Q9wFci4lzg58BbWpRHkqSmu/baa2fccsstMwC2bds29r3vfe8xAFu2bBn3ne98Z/K4cePyzDPP7Pv+978/6bvf/e7zli1btuoNb3jDi9/xjnc8OXfu3N2NrKslBT0zVwO/M0D7ZuDkVmSQJKnVLrjggk0XXHDBs7rYzz777KMXLFiw5cwzz+zbu3cvF1xwwVGLFi1a+6IXvWjXe97zng0XX3zxnFtuuWVNI+tq92VrkiQd0hYvXnz4rFmzdp122mm/Ajj//PM3rl69umvZsmWHNbIcb/0qSTokzJnTvevyy18+ossb7ntvuummR/YNn3feeY+fd955j+8bHzduHHfffffKRpdpQZckHRJmz560odHLzDqJXe6SJFWABV2SpAqwoEuSVAEWdEmSKsCCLklSBVjQJUlqsj179nDSSSe99LTTTjsW4PTTTz/2s5/97LR909/97ncfdeWVV848mHV42Zok6ZAwMX4xc8zedSP2+NS9Y+bs2pmzSz0+9ZOf/OTMY4455qlt27aNBbjmmmt+fvrpp7/4zW9+85b777+/60c/+lH3DTfc0PAT1upZ0CVJh4Qxe9dNGPPElSP2+FSmXQ4x+4CzrVmzZvzy5csnX3jhhesXL148E6Cnp2fX2972tk0f/vCH5zzwwAPdV1111c8nTJjQ8BPW6tnlLklSE1100UVzP/axj60bM2b/knvZZZdtuPPOO5937LHHPnXKKadsO9j1WNAlSWqSf/iHf5g8ffr0Pa985St/3X/aD37wg0lArF69uuvpp58+6HVZ0CVJapLvfe97h33rW9+a8pKXvGT++9///mPuueee55511lkvfPrpp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gi5JUgVY0CVJqgALuiRJFWBBlySpAizokiRVgAVdkqQKsKBLklQB/x/K4N14Nd6omQAAAABJRU5ErkJggg==\n",
"text/plain": [
""
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"dist4 = Table().values(-4*x).probability(probs)\n",
"Plots('-4X', dist4, '4X', dist3 )"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"tags": [
"remove-input",
"hide-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" VIDEO"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# VIDEO: SD: Linear Functions\n",
"\n",
"YouTubeVideo('zF-_2JwObjQ')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Linear Functions ###\n",
"\n",
"The graphs above help us visualize what happens to the SD when the random variable is transformed linearly, for example when changing units of measurement. Let $Y = aX + b$. Then\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"Var(Y) = E\\big{[} (Y-\\mu_Y)^2 \\big{]} &= E\\big{[} (aX + b - a\\mu_X - b)^2 \\big{]}\\\\ \n",
"&= a^2 E \\big{[} (X - \\mu_X)^2 \\big{]}\\\\ \n",
"&= a^2 \\sigma_X^2\n",
"\\end{align*}\n",
"$$\n",
"\n",
"Notice that the shift $b$ has no effect on the variance. This is consistent with what we saw in the first visualization above.\n",
"\n",
"Because the units of the variance are the square of the units of $X$, $Var(Y)$ is $a^2$ times the variance of $X$. That is,\n",
"\n",
"$$\n",
"Var(aX + b) = a^2Var(X), ~~~~~~~~~~~~~~~~~~ SD(aX + b) = |a|\\sigma_X\n",
"$$\n",
"\n",
"Notice that you get the same answer when the multiplicative constant is $a$ as when it is $-a$. That is what the two \"mirror image\" histograms had shown.\n",
"\n",
"In particular, it is very handy to remember that $SD(X) = SD(-X)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"Let $E(X) = 10$ and $SD(X) = 2$. Let $Y = 4 - 3X$. Find the expectation and SD of $Y$.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"$E(Y) = -26$, $SD(Y) = 6$\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### \"Computational\" Formula for Variance ###\n",
"An algebraic simplification of the formula for variance turns out to be very useful.\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"\\sigma_X^2 &= E\\big{(} (X-\\mu_X)^2 \\big{)} \\\\ \\\\\n",
"&= E(X^2 - 2X\\mu_X + \\mu_X^2) \\\\ \\\\\n",
"&= E(X^2) - 2\\mu_XE(X) + \\mu_X^2 \\\\ \\\\\n",
"&= E(X^2) - 2\\mu_X^2 + \\mu_X^2 \\\\ \\\\\n",
"&= E(X^2) - \\mu_X^2 \n",
"\\end{align*}\n",
"$$\n",
"\n",
"Thus the variance is the \"mean of the square minus the square of the mean.\" \n",
"\n",
"Apart from giving us an alternative way of calculating variance, the formula tells us something about the relation between $E(X^2)$ and $\\mu_X^2 = (E(X))^2$. Since variance is non-negative, the formula shows that \n",
"\n",
"$$\n",
"E(X^2) ~ \\ge ~ (E(X))^2\n",
"$$\n",
"\n",
"with equality only when $X$ is a constant.\n",
"\n",
"The formula is often called the \"computational\" formula for variance. But it can be be numerically inaccurate if the possible values of $X$ are large and numerous. For algebraic computation, however, it is very useful, as you will see in the calculations below."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"Return to the random variable $X$ that has distribution given by $P(X = -2) = 0.3$, $P(X = 2) = 0.5$, and $P(X = 3) = 0.2$. Earlier, you found $SD(X)$ by applying the definition of standard deviation. Now find $SD(X)$ by using the \"computational\" formula for variance.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"$2$\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"tags": [
"remove-input",
"hide-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" VIDEO"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# VIDEO: Variance of Indicator\n",
"\n",
"YouTubeVideo('lfJWb_s3MSI')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Indicator ###\n",
"The values of an indicator random variable are 0 and 1. Each of those two numbers is equal to its square. So if $I$ is an indicator, then $I^2 = I$, and thus\n",
"\n",
"$$\n",
"Var(I) = E(I^2) - [E(I)]^2 = E(I) - [E(I)]^2 = p - p^2 = p(1-p)\n",
"$$\n",
"\n",
"You should check that this variance is largest when $p = 0.5$. Take the square root to get\n",
"\n",
"$$\n",
"SD(I) = \\sqrt{p(1-p)}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Uniform ###\n",
"Let $U$ be uniform on $1, 2, 3, \\ldots, n$. Then\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"E(U^2) &= \\sum_{k=1}^n k^2 \\cdot \\frac{1}{n} \\\\ \\\\\n",
"&= \\frac{1}{n} \\sum_{k=1}^n k^2 \\\\ \\\\\n",
"&= \\frac{1}{n} \\cdot \\frac{n(n+1)(2n+1)}{6} \\\\ \\\\\n",
"&= \\frac{(n+1)(2n+1)}{6}\n",
"\\end{align*}\n",
"$$\n",
"\n",
"In the last-but-one step above, we used the formula for the sum of the first $n$ squares. \n",
"\n",
"We know that $E(U) = (n+1)/2$, so\n",
"\n",
"$$\n",
"Var(U) = \\frac{(n+1)(2n+1)}{6} - \\frac{(n+1)^2}{4}\n",
"= \\frac{n+1}{2} \\big{(} \\frac{2n+1}{3} - \\frac{n+1}{2} \\big{)}\n",
"= \\frac{n^2-1}{12}\n",
"$$\n",
"\n",
"and \n",
"\n",
"$$\n",
"SD(U) = \\sqrt{\\frac{n^2-1}{12}}\n",
"$$\n",
"\n",
"By shifting, this is the same as the SD of the uniform distribution on any $n$ consecutive integers. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Poisson ###\n",
"Let $X$ have the Poisson $(\\mu)$ distribution. In [Chapter 8](http://prob140.org/textbook/content/Chapter_08/04_Additivity.html#e-x-2-for-a-poisson-variable-x) we showed that \n",
"\n",
"$$\n",
"E(X^2) = \\mu^2 + \\mu\n",
"$$\n",
"\n",
"We also know that $E(X) = \\mu$. Thus\n",
"\n",
"$$\n",
"Var(X) = \\mu^2 + \\mu - \\mu^2 = \\mu\n",
"$$\n",
"\n",
"and \n",
"\n",
"$$\n",
"SD(X) = \\sqrt{\\mu}\n",
"$$\n",
"\n",
"So for example if $X$ has the Poisson $(5)$ distribution, then $E(X) = 5$ and $SD(X) = \\sqrt{5} \\approx 2.24$. In the this chapter and the next, we will try to figure out what that means."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}