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
306 changes: 290 additions & 16 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,110 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.7999999999999999\n"
]
}
],
"source": [
"#𝑃(𝐴∪𝐵)=0.6\n",
"A = 0.3\n",
"B = 0.6\n",
"unionAB=A+B-0.1\n",
"print(unionAB)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.16666666666666669\n"
]
}
],
"source": [
"#𝑃(𝐴∩𝐵𝐶)=0.2\n",
"\n",
"cond_AB=0.1/B\n",
"print(cond_AB)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.27999999999999997\n"
]
}
],
"source": [
"#𝑃(𝐴𝐶∩𝐵𝐶)=0.3\n",
"\n",
"AC=1-A\n",
"BC=1-B\n",
"AcnBc=AC*BC\n",
"print(AcnBc)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#𝑃((𝐴∩𝐵)𝐶)=0.9\n",
"1-0.1\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\n𝑃(𝐴∪𝐵)=0.6 is false\\n𝑃(𝐴∩𝐵𝐶)=0.2 is false\\n𝑃(𝐴∩(𝐵∪𝐵𝐶))=0.4 is false\\n\\n'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"𝑃(𝐴∪𝐵)=0.6 is false\n",
"𝑃(𝐴∩𝐵𝐶)=0.2 is false\n",
"𝑃(𝐴∩(𝐵∪𝐵𝐶))=0.4 is false\n",
"#𝑃(𝐴𝐶∩𝐵𝐶)=0.3 is false\n",
"\"\"\""
]
},
Expand All @@ -42,14 +140,114 @@
"**Hint**: Reposition means putting back the ball into the box after taking it out."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3333333333333333"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"W=10\n",
"R=12\n",
"B=8\n",
"S=sum([W,R,B])\n",
"W/S"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.36666666666666664"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"W=9\n",
"R=11\n",
"B=6\n",
"\n",
"R/S"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"W=9\n",
"R=12\n",
"B=7\n",
"S=sum(W,R,B)\n",
"9/S"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.39285714285714285"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"W=10\n",
"R=11\n",
"B=7\n",
"S=sum([W,R,B])\n",
"R/S"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\nyour solution here\\n'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"#1. Taking a white ball out 0.33\n",
"#2. Taking a white ball out after taking a black ball out. 0.3\n",
"#3. Taking a red ball out after taking a black and a red ball out. 0.36\n",
"#4. Taking a red ball out after taking a black and a red ball out with reposition.0.39\n",
"\"\"\""
]
},
Expand All @@ -70,15 +268,51 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'\\nyour solution here\\n'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"P(R|C)=0.5\n",
"C=0.4\n",
"R=0.1\n",
"|R n C| = (R|C) * (R)/(C)\n",
"the answer is 0.125\n",
"\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.125"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(0.5*0.1)/0.4"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -102,28 +336,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 40,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The events of wanting more street lighting and being a man are independent.\n"
]
}
],
"source": [
"# your code here"
"import pandas as pd\n",
"\n",
"data = {'Gender':['Men', 'Women'],\n",
" 'Total': [480, 520],\n",
" 'Yes':[324, 351],\n",
" 'No':[156, 160]}\n",
"\n",
"survey=pd.DataFrame(data)\n",
"survey.set_index('Gender', inplace=True)\n",
"survey\n",
"\n",
"total_responses = survey['Total'].sum()\n",
"prob_A = survey['Yes'].sum() / total_responses\n",
"prob_B = survey.loc['Men', 'Total'] / total_responses\n",
"\n",
"prob_A_given_B = survey.loc['Men', 'Yes'] / survey.loc['Men', 'Total']\n",
"prob_A_given_B\n",
"\n",
"if prob_A_given_B == prob_A:\n",
" print(\"The events of wanting more street lighting and being a man are independent.\")\n",
"else:\n",
" print(\"The events of wanting more street lighting and being a man are not independent.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'\\nyour solution here\\n'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\"\"\n",
"your solution here\n",
"\"\"\"\"0.675 probability the person who answered is a man. \n",
"The events of wanting more street lighting and being a man are independent\n",
"\"\"\""
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -137,7 +411,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down