Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 77 additions & 21 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\""
"# 𝑃(𝐴∪𝐵)=0.6\n",
"# 𝑃(𝐴𝐶∩𝐵𝐶)=0.3"
]
},
{
Expand All @@ -44,13 +43,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability of a white ball out: 0.3333333333333333\n",
"Probability of taking a white ball after taking a black ball: 0.09195402298850575\n",
"Probability of taking a red ball after taking a black and a red ball: 0.04334975369458128\n",
"Probability of taking a red ball after taking a black and a red ball put it back: 0.04266666666666667\n"
]
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\""
"total_white = 10\n",
"total_black = 8\n",
"total_red = 12\n",
"total_balls = total_white + total_black + total_red\n",
"\n",
"prob_white = total_white / total_balls\n",
"\n",
"prob_white_after_black = (total_white / (total_balls - 1)) * (total_black / total_balls)\n",
"\n",
"prob_red_after_black_and_red = (total_red / (total_balls - 2)) * (total_black / (total_balls - 1)) * (total_red - 1) / total_balls\n",
"\n",
"prob_red_after_black_and_red_put_back = (total_red / total_balls) * (total_black / total_balls) * (total_red / total_balls)\n",
"\n",
"print(\"Probability of a white ball out:\", prob_white)\n",
"print(\"Probability of taking a white ball after taking a black ball:\", prob_white_after_black)\n",
"print(\"Probability of taking a red ball after taking a black and a red ball:\", prob_red_after_black_and_red)\n",
"print(\"Probability of taking a red ball after taking a black and a red ball put it back:\", prob_red_after_black_and_red_put_back)"
]
},
{
Expand All @@ -70,13 +94,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability of rain given that the day started cloudy: 0.125\n"
]
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\""
"p_rain = 0.10 \n",
"p_cloudy_if_rain = 0.50 \n",
"p_cloudy = 0.40 \n",
"\n",
"p_rain_given_cloudy = (p_cloudy_if_rain * p_rain) / p_cloudy\n",
"\n",
"print(\"Probability of rain given that the day started cloudy:\", p_rain_given_cloudy)"
]
},
{
Expand All @@ -102,11 +138,33 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Yes No Total\n",
"Gender \n",
"Men 324 156 480\n",
"Women 351 169 520\n",
"Total 675 325 1000\n"
]
}
],
"source": [
"# your code here"
"answers = {\n",
" 'Gender': ['Men', 'Women', 'Total'],\n",
" 'Yes': [324, 351, 675],\n",
" 'No': [156, 169, 325],\n",
" 'Total': [480, 520, 1000]\n",
"}\n",
"\n",
"contingency_table = pd.DataFrame(answers)\n",
"contingency_table = contingency_table.set_index('Gender')\n",
"\n",
"print(contingency_table)"
]
},
{
Expand All @@ -115,15 +173,13 @@
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\""
"# The probability of wanting more street lighting does not depend on whether the respondent is male or female."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -137,7 +193,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down