diff --git a/your-code/main.ipynb b/your-code/main.ipynb index b8b7a9c..479fb99 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -19,13 +19,70 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "# P(A and B) = P(A) * P(B) # if A and B are independent\n", + "# P(A and B) = 0.01\n", + "\n", + "#P(A) * P(B)= 0.60*0.30\n", + "\n", + "## with this we can say that A and B are not independent!!! :D" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1.\n", + "\n", + "- P(A U B)= P(A) + P(B) - P(A and B)\n", + "- P(A U B)= 0.30 + 0.60 -0.10\n", + "- P(A U B)= 0.80
\n", + "The statement are **False**\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2. \n", + "- P(A)- P(A∩B)\n", + "- 0.3 - 0.1 = 0.2
\n", + "The statement are **true**\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3. \n", + "- 𝑃(𝐴∩(𝐡βˆͺ𝐡𝐢))=0.4 \n", + "\n", + "- P(A∩B) + P(A) - P(A∩B)\n", + "- 0.1 + 0.3 -0.1 = 0.3
\n", + "The statement are **False**\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4.\n", + "- 𝑃(𝐴𝐢∩𝐡𝐢) = 1 - 𝑃(𝐴βˆͺ𝐡) \n", + "- = 1 - 0.8 = 0.2
\n", + "The statement are **False**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "5.\n", + "- 𝑃((𝐴∩𝐡)𝐢) = 1 - 𝑃(𝐴∩𝐡) \n", + "- = 1 - 0.1 = 0.9
\n", + "The statement are **True**" ] }, { @@ -43,14 +100,23 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "w = 10
\n", + "r = 12
\n", + "b = 8
\n", + "\n", + "1. P(w)= 10/30 = 0,33\n", + "2. P(w) = 10/29= 0,34\n", + "3. P(r)= 12/28= 0,42\n", + "\n", + "4. P = P(b) * P(r) * P(r2)\n", + "\n", + "P= (8/30) * (12/30) * (12/30)
\n", + "P = 0.042
\n", + "\n", + "**P(r2)= probability of taking the red ball again**\n" ] }, { @@ -68,15 +134,38 @@ "What is the probability of rain, given the day started cloudy?" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "ca= 0.50
\n", + "rb=0.40
\n", + "m=0.1
\n", + "\n", + "**P(A|B) = (P(B|A) * P (A))/P (B)**
\n", + "\n", + "P= (0,1 * 0,50) / 0,40
\n", + "P= 0.125 * 100 = 12,5" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "12.5" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "((0.1*0.50)/0.40)*100" ] }, { @@ -102,28 +191,129 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GenderYesNototal
0male324156480
1female351169520
\n", + "
" + ], + "text/plain": [ + " Gender Yes No total\n", + "0 male 324 156 480\n", + "1 female 351 169 520" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "import pandas as pd\n", + "\n", + "data = {'Gender': ['male', 'female'],\n", + " 'Yes': ['324', '351'],\n", + " 'No': ['156', '169'],\n", + " 'total': ['480','520']}\n", + "\n", + "df = pd.DataFrame(data)\n", + "\n", + "df" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The answer is yes, so the person that answered thinks that more street lighting is needed.
\n", + "The person who answered is a man.
\n", + "\n", + "male= 480
\n", + "male_yes= 324
\n", + "male_no= 156
\n", + "\n", + "female= 520
\n", + "female_yes= 351
\n", + "female_no= 169
\n", + "\n", + "\n", + "P(A|B) = male_yes / male
\n", + "P(A|B) = 324 / 480 = 0.675
\n", + "\n", + "\n", + "P(A) = (male_yes + female_yes) / (male + female)
\n", + "P(A) = (324 + 351) / (480 + 520) = 0.675
\n", + "\n", + "**RESULT** - P(A|B) = P(A) the events are independent.
\n", + "Based on the data, there is no strong indication that the desire for more street lighting depends on whether one is male or female." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.675\n", + "0.675\n" + ] + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "print(324/480)\n", + "print((324+351)/(480+520))" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -137,7 +327,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.10.9" } }, "nbformat": 4,