Skip to content

Commit

Permalink
Merge pull request #28 from QuantEcon/change-day
Browse files Browse the repository at this point in the history
Change Day 2 to Day 3 in Exercise 4 and Reformat
  • Loading branch information
HumphreyYang authored Jul 5, 2023
2 parents 7e0bccf + 28e3dca commit 2ecf2fe
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 33 deletions.
97 changes: 82 additions & 15 deletions day-04/exercise_set_4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -695,7 +762,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
27 changes: 9 additions & 18 deletions day-04/exercise_set_4_with_solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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."
]
},
{
Expand All @@ -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."
]
},
{
Expand All @@ -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."
]
},
{
Expand All @@ -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)?"
]
},
{
Expand Down

0 comments on commit 2ecf2fe

Please sign in to comment.