From 7479c6f0189f66ac4614bc4c3d2d5eab3e6561b5 Mon Sep 17 00:00:00 2001 From: Tiago Mateus Date: Wed, 15 Nov 2023 11:36:50 +0000 Subject: [PATCH] lab done --- your-code/main.ipynb | 103 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 19 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index b8b7a9c..c51d115 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -24,7 +24,11 @@ "outputs": [], "source": [ "\"\"\"\n", - "your solution here\n", + "𝑃(𝐴βˆͺ𝐡) = 0.8 false\n", + "𝑃(𝐴∩𝐡𝐢) = 0.9 false\n", + "𝑃(𝐴∩(𝐡βˆͺ𝐡𝐢)) = 0.3 false\n", + "𝑃(𝐴𝐢∩𝐡𝐢)=0.3 true\n", + "𝑃((𝐴∩𝐡)𝐢) = 0.9 true\n", "\"\"\"" ] }, @@ -44,13 +48,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.03515625" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "white = 12\n", + "red = 12\n", + "black = 8\n", + "\n", + "total = white + black + red\n", + "\n", + "#1.\n", + "pred = white / total\n", + "\n", + "#2.\n", + "pblack = black / total\n", + "\n", + "p2 = pblack * (red / (total - 1))\n", + "\n", + "#3.\n", + "p3 = p2 * ((red - 1)/(total - 2))\n", + "\n", + "#4.\n", + "p4 = pred * pred * pblack" ] }, { @@ -70,13 +101,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.125" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "pcloudy = 0.4\n", + "prainy = 0.1\n", + "pcar = 0.5\n", + "\n", + "prac = (pcar * prainy) / pcloudy\n", + "prac" ] }, { @@ -106,24 +151,44 @@ "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# if independent p(a) = p(a|b) e p(b) = p(b|a) AND p(a.int.b) = p(a) * p(b)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "pyes = (324 + 351) /(520 + 480)\n", + "\n", + "pyesmen = 324 / 480\n", + "\n", + "pmen = 0.48\n", + "\n", + "pmenyes = (pyesmen * pmen) / pyes\n", + "\n", + "pmenyes == pmen\n", + "pyesmen == pyes\n", + "\n", + "# if true they are independent" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -137,7 +202,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.10.9" } }, "nbformat": 4,