ipynb β’ Lines: 1255{
"cells": [
{
"cell_type": "markdown",
"id": "4caafec3",
"metadata": {},
"source": [
"# Probability 2: Loaded dice \n",
"\n",
"In this assignment you will be reinforcening your intuition about the concepts covered in the lectures by taking the example with the dice to the next level. \n",
"\n",
"This assignment will not evaluate your coding skills but rather your intuition and analytical skills. You can answer any of the exercise questions by any means necessary, you can take the analytical route and compute the exact values or you can alternatively create some code that simulates the situations at hand and provide approximate values (grading will have some tolerance to allow approximate solutions). It is up to you which route you want to take! \n",
"\n",
"This graded notebook is different from what you might seen in other assignments of this specialization since only your answers are graded and not the code you used to get that answer. For every exercise there is a blank cell that you can use to make your calculations, this cell has just been placed there for you convenience but **will not be graded** so you can leave empty if you want to. \n",
"\n",
"However **you need to submit the answer for that exercise by running the cell that contains the `utils.exercise_x()` function**. By running this cell a widget will appear in which you can place your answers. Don't forget to click the `Save your answer!` button."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "da0fcf2f",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import utils"
]
},
{
"cell_type": "markdown",
"id": "4546a127",
"metadata": {},
"source": [
"## Some concept clarifications π²π²π²\n",
"\n",
"During this assignment you will be presented with various scenarios that involve dice. Usually dice can have different numbers of sides and can be either fair or loaded.\n",
"\n",
"- A fair dice has equal probability of landing on every side.\n",
"- A loaded dice does not have equal probability of landing on every side. Usually one (or more) sides have a greater probability of showing up than the rest.\n",
"\n",
"Let's get started!"
]
},
{
"cell_type": "markdown",
"id": "c8f09f02",
"metadata": {},
"source": [
"## Exercise 1:\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "3510c610",
"metadata": {},
"source": [
"Given a 6-sided fair dice (all of the sides have equal probability of showing up), compute the mean and variance for the probability distribution that models said dice. The next figure shows you a visual represenatation of said distribution:\n",
"\n",
"<img src=\"./images/fair_dice.png\" style=\"height: 300px;\"/>\n",
"\n",
"**Submission considerations:**\n",
"- Submit your answers as floating point numbers with three digits after the decimal point\n",
"- Example: To submit the value of 1/4 enter 0.250"
]
},
{
"cell_type": "markdown",
"id": "5ee9b479",
"metadata": {},
"source": [
"Hints: \n",
"- You can use [np.random.choice](https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html) to simulate a fair dice.\n",
"- You can use [np.mean](https://numpy.org/doc/stable/reference/generated/numpy.mean.html) and [np.var](https://numpy.org/doc/stable/reference/generated/numpy.var.html) to compute the mean and variance of a numpy array."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "df437e8e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.9166666666666665"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"np.var([1,2,3,4,5,6])\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "db9477e7",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4539d293b19d4133be128bada752a4a0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='Mean:')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3cd0daa75be34a2f95beb0d63bf6679b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='Variance:')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a2c01115f0c44fce8748a62becc2d561",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f3e705157fe14e11be886a9e2863d976",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_1()\n"
]
},
{
"cell_type": "markdown",
"id": "d43dcbbd",
"metadata": {},
"source": [
"## Exercise 2:\n",
"\n",
"Now suppose you are throwing the dice (same dice as in the previous exercise) two times and recording the sum of each throw. Which of the following `probability mass functions` will be the one you should get?\n",
"\n",
"<table><tr>\n",
"<td> <img src=\"./images/hist_sum_6_side.png\" style=\"height: 300px;\"/> </td>\n",
"<td> <img src=\"./images/hist_sum_5_side.png\" style=\"height: 300px;\"/> </td>\n",
"<td> <img src=\"./images/hist_sum_6_uf.png\" style=\"height: 300px;\"/> </td>\n",
"</tr></table>\n"
]
},
{
"cell_type": "markdown",
"id": "605c58c0",
"metadata": {},
"source": [
"Hints: \n",
"- You can use numpy arrays to hold the results of many throws.\n",
"- You can sum to numpy arrays by using the `+` operator like this: `sum = first_throw + second_throw`\n",
"- To simulate multiple throws of a dice you can use list comprehension or a for loop"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e9a8b2ed",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "d4d5dcf9",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "535eea3b403f43dea3f00c2fccf7dd71",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='Your answer:', options=('left', 'center', 'right'), value='left')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0cf5de02e509433e9912b174d9100c2a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c786e1bc6a1e4f2db024089ff18d7250",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_2()\n"
]
},
{
"cell_type": "markdown",
"id": "adfb889c",
"metadata": {},
"source": [
"## Exercise 3:\n",
"\n",
"Given a fair 4-sided dice, you throw it two times and record the sum. The figure on the left shows the probabilities of the dice landing on each side and the right figure the histogram of the sum. Fill out the probabilities of each sum (notice that the distribution of the sum is symmetrical so you only need to input 4 values in total):\n",
"\n",
"<img src=\"./images/4_side_hists.png\" style=\"height: 300px;\"/>\n",
"\n",
"**Submission considerations:**\n",
"- Submit your answers as floating point numbers with three digits after the decimal point\n",
"- Example: To submit the value of 1/4 enter 0.250"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "342ca685",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "e0a24beb",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7b828a78ab4143aca4c59c4fc6307525",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='P for sum=2|8', style=DescriptionStyle(description_width='initial'))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "33181d46195549e4a54c72310790cb37",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='P for sum=3|7:', style=DescriptionStyle(description_width='initial'))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5aa35dc626ee439a8b6a4fe9b408ecb7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='P for sum=4|6:', style=DescriptionStyle(description_width='initial'))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2b10c5ec729e42819071f255437d77b8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='P for sum=5:', style=DescriptionStyle(description_width='initial'))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d99036c79af343039a511ea23b2f879f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6765c6065abe406cb8b56d6b93ff01dc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_3()"
]
},
{
"cell_type": "markdown",
"id": "108837bd",
"metadata": {},
"source": [
"## Exercise 4:\n",
"\n",
"Using the same scenario as in the previous exercise. Compute the mean and variance of the sum of the two throws and the covariance between the first and the second throw:\n",
"\n",
"<img src=\"./images/4_sided_hist_no_prob.png\" style=\"height: 300px;\"/>\n",
"\n",
"\n",
"Hints:\n",
"- You can use [np.cov](https://numpy.org/doc/stable/reference/generated/numpy.cov.html) to compute the covariance of two numpy arrays (this may not be needed for this particular exercise)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f4eadc3c",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4e662b9b",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bc37f902e49641b38acd2aecb23d4573",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='Mean:')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "08b7e40886c0444a9718e29093dc48ea",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='Variance:')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b59bdef067ed438bbe79d009759e7bdf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatText(value=0.0, description='Covariance:')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "04161e534fb348209e8c31b25772335f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d7fc3bab976a449797390860b5ea70e8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_4()"
]
},
{
"cell_type": "markdown",
"id": "714e099b",
"metadata": {},
"source": [
"## Exercise 5:\n",
"\n",
"\n",
"Now suppose you are have a loaded 4-sided dice (it is loaded so that it lands twice as often on side 2 compared to the other sides): \n",
"\n",
"\n",
"<img src=\"./images/4_side_uf.png\" style=\"height: 300px;\"/>\n",
"\n",
"You are throwing it two times and recording the sum of each throw. Which of the following `probability mass functions` will be the one you should get?\n",
"\n",
"<table><tr>\n",
"<td> <img src=\"./images/hist_sum_4_4l.png\" style=\"height: 300px;\"/> </td>\n",
"<td> <img src=\"./images/hist_sum_4_3l.png\" style=\"height: 300px;\"/> </td>\n",
"<td> <img src=\"./images/hist_sum_4_uf.png\" style=\"height: 300px;\"/> </td>\n",
"</tr></table>"
]
},
{
"cell_type": "markdown",
"id": "ecb27c1b",
"metadata": {},
"source": [
"Hints: \n",
"- You can use the `p` parameter of [np.random.choice](https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html) to simulate a loaded dice."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a35573ec",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "3104e647",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e226acb5143b4781ad45d5574e10ce0e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='Your answer:', options=('left', 'center', 'right'), value='left')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "68f0b191bf194e8b816ed5ef07c2c35c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5cabdd71f74542f18d131189918e5ec8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_5()"
]
},
{
"cell_type": "markdown",
"id": "0d0f3429",
"metadata": {},
"source": [
"## Exercise 6:\n",
"\n",
"You have a 6-sided dice that is loaded so that it lands twice as often on side 3 compared to the other sides:\n",
"\n",
"<img src=\"./images/loaded_6_side.png\" style=\"height: 300px;\"/>\n",
"\n",
"You record the sum of throwing it twice. What is the highest value (of the sum) that will yield a cumulative probability lower or equal to 0.5?\n",
"\n",
"<img src=\"./images/loaded_6_cdf.png\" style=\"height: 300px;\"/>\n",
"\n",
"Hints:\n",
"- The probability of side 3 is equal to $\\frac{2}{7}$"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10feaaa8",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "963e5763",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3ef452296c474893aa22580042fad01e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"IntSlider(value=2, continuous_update=False, description='Sum:', max=12, min=2)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4c4cde02b68840c69d8f3b39e6c5f42f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0a7393f9ba944f869f3ab27358c8408a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_6()"
]
},
{
"cell_type": "markdown",
"id": "f6684426",
"metadata": {},
"source": [
"## Exercise 7:\n",
"\n",
"Given a 6-sided fair dice you try a new game. You only throw the dice a second time if the result of the first throw is **lower** or equal to 3. Which of the following `probability mass functions` will be the one you should get given this new constraint?\n",
"\n",
"<table><tr>\n",
"<td> <img src=\"./images/6_sided_cond_green.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_blue.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_red.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_brown.png\" style=\"height: 250px;\"/> </td>\n",
"\n",
"</tr></table>\n",
"\n",
"Hints:\n",
"- You can simulate the second throws as a numpy array and then make the values that met a certain criteria equal to 0 by using [np.where](https://numpy.org/doc/stable/reference/generated/numpy.where.html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e64d178",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "82a4db40",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a6ecbfc2c23344c38025817e75d37620",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='Your answer:', options=('left-most', 'left-center', 'right-center', 'right-most'), β¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "233d867f795e49d097c24b3b8c664b75",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e463913c3cc44d69ae2309f410f38c16",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_7()"
]
},
{
"cell_type": "markdown",
"id": "ba973eaf",
"metadata": {},
"source": [
"## Exercise 8:\n",
"\n",
"Given the same scenario as in the previous exercise but with the twist that you only throw the dice a second time if the result of the first throw is **greater** or equal to 3. Which of the following `probability mass functions` will be the one you should get given this new constraint?\n",
"\n",
"<table><tr>\n",
"<td> <img src=\"./images/6_sided_cond_green2.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_blue2.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_red2.png\" style=\"height: 250px;\"/> </td>\n",
"<td> <img src=\"./images/6_sided_cond_brown2.png\" style=\"height: 250px;\"/> </td>\n",
"\n",
"</tr></table>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d25300f",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "33bb9fd2",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4787738d813a40b89af1f0bdb7575469",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='Your answer:', options=('left-most', 'left-center', 'right-center', 'right-most'), β¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "97dd4aba1c4e46bfbd31930637898c6f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6653c5ce8a35480f8ffabdde7841d89e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_8()"
]
},
{
"cell_type": "markdown",
"id": "017e9b22",
"metadata": {},
"source": [
"## Exercise 9:\n",
"\n",
"Given a n-sided fair dice. You throw it twice and record the sum. How does increasing the number of sides `n` of the dice impact the mean and variance of the sum and the covariance of the joint distribution?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "645a9b74",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "907412da",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"As the number of sides in the die increases:\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "70b3007968e647dd9bf87517553a6c1e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='The mean of the sum:', options=('stays the same', 'increases', 'decreases'), value=β¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f97fbec334a54b76a8ee84e1f13e34b3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='The variance of the sum:', options=('stays the same', 'increases', 'decreases'), vaβ¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1f2cd3a5e2c74f188418c449d4b607d7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='The covariance of the joint distribution:', options=('stays the same', 'increases',β¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7c6e89395c5e45f09b7e5ac3d5242de6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "35dfe2a6a03c444286fbedd057a3119c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_9()"
]
},
{
"cell_type": "markdown",
"id": "fcf9b3ac",
"metadata": {},
"source": [
"## Exercise 10:\n",
"\n",
"Given a 6-sided loaded dice. You throw it twice and record the sum. Which of the following statements is true?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "008c5858",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "99373567",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0edf91e0d60a4a988f6a7af48448322d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RadioButtons(layout=Layout(width='max-content'), options=('the mean and variance is the same regardless of whiβ¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e1a9fadf901e49b4993f2b55cc99ad19",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4247dca8a04445e2a353ad80be2e517a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_10()"
]
},
{
"cell_type": "markdown",
"id": "0a84afef",
"metadata": {},
"source": [
"## Exercise 11:\n",
"\n",
"Given a fair n-sided dice. You throw it twice and record the sum but the second throw depends on the result of the first one such as in exercises 7 and 8. Which of the following statements is true?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cb6ad84",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "9b048c03",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0ba470ff38ce44399b272a435cb7a066",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RadioButtons(layout=Layout(width='max-content'), options=('changing the direction of the inequality will changβ¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0b23d25021694d9582395352565b21b7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "857c4830956e4cd7b49d47c473e01535",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_11()"
]
},
{
"cell_type": "markdown",
"id": "f8a1a8a3",
"metadata": {},
"source": [
"## Exercise 12:\n",
"\n",
"Given a n-sided dice (could be fair or not). You throw it twice and record the sum (there is no dependance between the throws). If you are only given the histogram of the sums can you use it to know which are the probabilities of the dice landing on each side?\n",
"\n",
"In other words, if you are provided with only the histogram of the sums like this one:\n",
"<td> <img src=\"./images/hist_sum_6_side.png\" style=\"height: 300px;\"/> </td>\n",
"\n",
"Could you use it to know the probabilities of the dice landing on each side? Which will be equivalent to finding this histogram:\n",
"<img src=\"./images/fair_dice.png\" style=\"height: 300px;\"/>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b42149cf",
"metadata": {},
"outputs": [],
"source": [
"# You can use this cell for your calculations (not graded)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "33a2e4d9",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "41a2c26dd7a645c480a37b2c52aa1e7a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RadioButtons(layout=Layout(width='max-content'), options=('yes, but only if one of the sides is loaded', 'no, β¦"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d05f8664d359494a8331c2ff05e465de",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Save your answer!', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "778ce35e8ffd4ac59434e6edde501c7a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Run this cell to submit your answer\n",
"utils.exercise_12()"
]
},
{
"cell_type": "markdown",
"id": "1635ca7c",
"metadata": {},
"source": [
"## Before Submitting Your Assignment\n",
"\n",
"Run the next cell to check that you have answered all of the exercises"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "c6822278",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"All answers saved, you can submit the assignment for grading!\n"
]
}
],
"source": [
"utils.check_submissions()"
]
},
{
"cell_type": "markdown",
"id": "5286008f",
"metadata": {},
"source": [
"**Congratulations on finishing this assignment!**\n",
"\n",
"During this assignment you tested your knowledge on probability distributions, descriptive statistics and visual interpretation of these concepts. You had the choice to compute everything analytically or create simulations to assist you get the right answer. You probably also realized that some exercises could be answered without any computations just by looking at certain hidden queues that the visualizations revealed.\n",
"\n",
"**Keep up the good work!**\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c0ca54bb",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}