diff --git a/day-04/exercise_set_4.ipynb b/day-04/exercise_set_4.ipynb index 0399051..496ac9d 100644 --- a/day-04/exercise_set_4.ipynb +++ b/day-04/exercise_set_4.ipynb @@ -103,19 +103,7 @@ "source": [ "### Exercise 2\n", "\n", - "In this exercise, your tasks are the followings:\n", - "\n", - "**Exercise 2.1** Draw 1000 independent draws from the standard normal distribution using [`scipy.stats`](https://docs.scipy.org/doc/scipy/reference/stats.html).\n", - "\n", - "**Exercise 2.2** Calculate the sample mean and variance of the draws and compare them to the theoretical values.\n", - "\n", - "**Exercise 2.3** Visualize the empirical distribution of the draws using a histogram. Mark the sample mean and $\\pm$ one standard deviation using vertical lines.\n", - "\n", - "**Exercise 2.4** Calculate the probability that a draw from the distribution is less than 0 and compare it to the proportion of the sample that is less than 0.\n", - "\n", - "**Exercise 2.5** How do the results in question 3 change with different sample sizes? Try to draw 10, 100, 500, 1000, and 10000 samples. Repeat 100 times for each sample size and plot the results. What do you observe when comparing the sample estimates to the population parameters (the ground truth)?\n", - "\n", - "Use the following imports to get started." + "In this exercise, use the following imports to get started." ] }, { @@ -129,6 +117,85 @@ "from scipy.stats import norm" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2.1** Draw 1000 independent draws from the standard normal distribution using [`scipy.stats`](https://docs.scipy.org/doc/scipy/reference/stats.html)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Put your solution here" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2.2** Calculate the sample mean and variance of the draws and compare them to the theoretical values." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Put your solution here" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2.3** Visualize the empirical distribution of the draws using a histogram. Mark the sample mean and $\\pm$ one standard deviation using vertical lines." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Put your solution here" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2.4** Calculate the probability that a draw from the distribution is less than 0 and compare it to the proportion of the sample that is less than 0." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Put your solution here" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2.5** Will results in exercise 2.3 change with different \n", + "sample sizes? \n", + "\n", + "Try to draw 10, 100, 500, 1000, and 10000 samples. Repeat 100 times for each sample size and plot the results. What do you observe when comparing the sample estimates to the population parameters (the ground truth)?" + ] + }, { "cell_type": "code", "execution_count": null, @@ -505,7 +572,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "On day 2, we generated 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", + "On day 3, we generated 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", "\n", "$$\n", "f(x; \\alpha) = \\alpha \\exp(-\\alpha x)\n", @@ -695,7 +762,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.16" } }, "nbformat": 4, diff --git a/day-04/exercise_set_4_with_solution.ipynb b/day-04/exercise_set_4_with_solution.ipynb index 43ac2ab..52920bf 100644 --- a/day-04/exercise_set_4_with_solution.ipynb +++ b/day-04/exercise_set_4_with_solution.ipynb @@ -152,19 +152,7 @@ "source": [ "### Exercise 2\n", "\n", - "In this exercise, your tasks are the followings:\n", - "\n", - "**Exercise 2.1** Draw 1000 independent draws from the standard normal distribution using [`scipy.stats`](https://docs.scipy.org/doc/scipy/reference/stats.html).\n", - "\n", - "**Exercise 2.2** Calculate the sample mean and variance of the draws and compare them to the theoretical values.\n", - "\n", - "**Exercise 2.3** Visualize the empirical distribution of the draws using a histogram. Mark the sample mean and $\\pm$ one standard deviation using vertical lines.\n", - "\n", - "**Exercise 2.4** Calculate the probability that a draw from the distribution is less than 0 and compare it to the proportion of the sample that is less than 0.\n", - "\n", - "**Exercise 2.5** How do the results in question 3 change with different sample sizes? Try to draw 10, 100, 500, 1000, and 10000 samples. Repeat 100 times for each sample size and plot the results. What do you observe when comparing the sample estimates to the population parameters (the ground truth)?\n", - "\n", - "Use the following imports to get started." + "In this exercise, use the following imports to get started." ] }, { @@ -191,7 +179,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.1**" + "**Exercise 2.1** Draw 1000 independent draws from the standard normal distribution using [`scipy.stats`](https://docs.scipy.org/doc/scipy/reference/stats.html).\n" ] }, { @@ -213,7 +201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.2**" + "**Exercise 2.2** Calculate the sample mean and variance of the draws and compare them to the theoretical values." ] }, { @@ -237,7 +225,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.3**" + "**Exercise 2.3** Visualize the empirical distribution of the draws using a histogram. Mark the sample mean and $\\pm$ one standard deviation using vertical lines." ] }, { @@ -259,7 +247,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.4**" + "**Exercise 2.4** Calculate the probability that a draw from the distribution is less than 0 and compare it to the proportion of the sample that is less than 0." ] }, { @@ -285,7 +273,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.5**" + "**Exercise 2.5** Will results in exercise 2.3 change with different \n", + "sample sizes? \n", + "\n", + "Try to draw 10, 100, 500, 1000, and 10000 samples. Repeat 100 times for each sample size and plot the results. What do you observe when comparing the sample estimates to the population parameters (the ground truth)?" ] }, {