Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RamamAgarwal authored Jul 17, 2024
1 parent bcb7d67 commit 06a81e4
Show file tree
Hide file tree
Showing 2 changed files with 309 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Conditional Probability.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "36a13cbb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Conditional probabilities P(B_i|A): [0.9615384615384615, 0.038461538461538464]\n"
]
}
],
"source": [
"def conditional(P_A_given_B, P_B):\n",
" # Calculate the total probability P(A)\n",
" P_A = 0\n",
" for i in range(len(P_B)):\n",
" P_A += P_A_given_B[i] * P_B[i]\n",
"\n",
" # Calculate P(B_i|A) for each i\n",
" P_B_given_A = []\n",
" for i in range(len(P_B)):\n",
" P_B_given_A.append(P_A_given_B[i] * P_B[i] / P_A)\n",
"\n",
" return P_B_given_A\n",
"\n",
"# Example usage\n",
"P_A_given_B = [250/2000, 5/1000] # Replace with actual values\n",
"P_B = [0.5, 0.5] # Replace with actual values\n",
"\n",
"P_B_given_A = conditional(P_A_given_B, P_B)\n",
"print(\"Conditional probabilities P(B_i|A):\", P_B_given_A)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 06a81e4

Please sign in to comment.