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
240 changes: 215 additions & 25 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 </br>\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 </br>\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 </br>\n",
"The statement are **False**\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"4.\n",
"- 𝑃(𝐴𝐶∩𝐵𝐶) = 1 - 𝑃(𝐴∪𝐵) \n",
"- = 1 - 0.8 = 0.2 </br>\n",
"The statement are **False**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"5.\n",
"- 𝑃((𝐴∩𝐵)𝐶) = 1 - 𝑃(𝐴∩𝐵) \n",
"- = 1 - 0.1 = 0.9 </br>\n",
"The statement are **True**"
]
},
{
Expand All @@ -43,14 +100,23 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\""
"w = 10 </br>\n",
"r = 12 </br>\n",
"b = 8 </br>\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)</br>\n",
"P = 0.042</br>\n",
"\n",
"**P(r2)= probability of taking the red ball again**\n"
]
},
{
Expand All @@ -68,15 +134,38 @@
"What is the probability of rain, given the day started cloudy?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ca= 0.50</br>\n",
"rb=0.40</br>\n",
"m=0.1</br>\n",
"\n",
"**P(A|B) = (P(B|A) * P (A))/P (B)**</br>\n",
"\n",
"P= (0,1 * 0,50) / 0,40</br>\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"
]
},
{
Expand All @@ -102,28 +191,129 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Gender</th>\n",
" <th>Yes</th>\n",
" <th>No</th>\n",
" <th>total</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>male</td>\n",
" <td>324</td>\n",
" <td>156</td>\n",
" <td>480</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>female</td>\n",
" <td>351</td>\n",
" <td>169</td>\n",
" <td>520</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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.</br>\n",
"The person who answered is a man.</br>\n",
"\n",
"male= 480</br>\n",
"male_yes= 324</br>\n",
"male_no= 156</br>\n",
"\n",
"female= 520</br>\n",
"female_yes= 351</br>\n",
"female_no= 169</br>\n",
"\n",
"\n",
"P(A|B) = male_yes / male </br>\n",
"P(A|B) = 324 / 480 = 0.675</br>\n",
"\n",
"\n",
"P(A) = (male_yes + female_yes) / (male + female) </br>\n",
"P(A) = (324 + 351) / (480 + 520) = 0.675</br>\n",
"\n",
"**RESULT** - P(A|B) = P(A) the events are independent. </br>\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"
},
Expand All @@ -137,7 +327,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down