{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "remove_input" ] }, "outputs": [], "source": [ "path_data = '../../data/'\n", "\n", "import numpy as np\n", "import pandas as pd\n", "from scipy import stats\n", "\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "plt.style.use('fivethirtyeight')\n", "\n", "import warnings\n", "warnings.filterwarnings('ignore')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# The Variability of the Sample Mean\n", "By the Central Limit Theorem, the probability distribution of the mean of a large random sample is roughly normal. The bell curve is centered at the population mean. Some of the sample means are higher, and some lower, but the deviations from the population mean are roughly symmetric on either side, as we have seen repeatedly. Formally, probability theory shows that the sample mean is an *unbiased* estimate of the population mean.\n", "\n", "In our simulations, we also noticed that the means of larger samples tend to be more tightly clustered around the population mean than means of smaller samples. In this section, we will quantify the variability of the sample mean and develop a relation between the variability and the sample size." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's start with our table of flight delays. The mean delay is about 16.7 minutes, and the distribution of delays is skewed to the right." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Delay | \n", "
---|---|
0 | \n", "257 | \n", "
1 | \n", "28 | \n", "
2 | \n", "-3 | \n", "
3 | \n", "0 | \n", "
4 | \n", "64 | \n", "
... | \n", "... | \n", "
13820 | \n", "-4 | \n", "
13821 | \n", "8 | \n", "
13822 | \n", "3 | \n", "
13823 | \n", "-1 | \n", "
13824 | \n", "-2 | \n", "
13825 rows × 1 columns
\n", "\n", " | Sample Size n | \n", "SD of 10,000 Sample Means | \n", "pop_sd/sqrt(n) | \n", "
---|---|---|---|
0 | \n", "25 | \n", "8.035955 | \n", "7.896040 | \n", "
1 | \n", "50 | \n", "5.607407 | \n", "5.583343 | \n", "
2 | \n", "75 | \n", "4.592538 | \n", "4.558781 | \n", "
3 | \n", "100 | \n", "3.977641 | \n", "3.948020 | \n", "
4 | \n", "125 | \n", "3.534429 | \n", "3.531216 | \n", "
5 | \n", "150 | \n", "3.222688 | \n", "3.223545 | \n", "
6 | \n", "175 | \n", "3.016842 | \n", "2.984423 | \n", "
7 | \n", "200 | \n", "2.808212 | \n", "2.791672 | \n", "
8 | \n", "225 | \n", "2.667100 | \n", "2.632013 | \n", "
9 | \n", "250 | \n", "2.510093 | \n", "2.496947 | \n", "