{ "cells": [ { "cell_type": "markdown", "id": "8119837f", "metadata": {}, "source": [ "# Tutorial exercises: Sampling\n", "\n", "In these exercises we again work with the Brexdex data\n", "\n", "We are going to investigate how the sampling distribution of the mean depends on $n$, the relationship between SEM and $\\sqrt{n}$, and how we assess whether a distribution, such as the sampling distribution of the mean, is Normal." ] }, { "cell_type": "markdown", "id": "79456fc9", "metadata": {}, "source": [ "### Set up Python libraries\n", "\n", "As usual, run the code cell below to import the relevant Python libraries" ] }, { "cell_type": "code", "execution_count": 1, "id": "5cd335fe", "metadata": {}, "outputs": [], "source": [ "# Set-up Python libraries - you need to run this but you don't need to change it\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import scipy.stats as stats\n", "import pandas as pd\n", "import seaborn as sns\n", "sns.set_theme(style='white')\n", "import statsmodels.api as sm\n", "import statsmodels.formula.api as smf\n", "import warnings \n", "warnings.simplefilter('ignore', category=FutureWarning)" ] }, { "cell_type": "markdown", "id": "fcf4f280", "metadata": {}, "source": [ "## Import and plot the data\n", "\n", "Let's remind ourselves of the dataset we are working with" ] }, { "cell_type": "code", "execution_count": 13, "id": "466ab767", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ID_code | \n", "score | \n", "
---|---|---|
0 | \n", "186640 | \n", "53 | \n", "
1 | \n", "588140 | \n", "90 | \n", "
2 | \n", "977390 | \n", "30 | \n", "
3 | \n", "948470 | \n", "42 | \n", "
4 | \n", "564360 | \n", "84 | \n", "
... | \n", "... | \n", "... | \n", "
9995 | \n", "851780 | \n", "81 | \n", "
9996 | \n", "698340 | \n", "45 | \n", "
9997 | \n", "693580 | \n", "51 | \n", "
9998 | \n", "872730 | \n", "78 | \n", "
9999 | \n", "385642 | \n", "88 | \n", "
10000 rows × 2 columns
\n", "