diff --git a/your-code/main.ipynb b/your-code/main.ipynb index b8b7a9c..f3c3ea8 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -23,9 +23,8 @@ "metadata": {}, "outputs": [], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "# 𝑃(𝐴βˆͺ𝐡)=0.6\n", + "# 𝑃(𝐴𝐢∩𝐡𝐢)=0.3" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -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" }, @@ -137,7 +193,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.10.9" } }, "nbformat": 4,