cmkl_assignments/fall-2024/math/mat-204/Game.ipynb

376 lines
90 KiB
Plaintext
Raw Normal View History

{
"cells": [
2024-11-23 20:14:21 +07:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# MAT-204:00010 - Probability\n",
"Author: Thanawin Pattanaphol - Date: 23th December 2024 - Description: Basic probability calculations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Importing Libraries"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 281,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [],
"source": [
"import pandas as pd \n",
"from matplotlib_venn import venn3\n",
"from matplotlib import pyplot as plt \n",
"\n",
"Dat = pd.read_csv('DataLoL.csv')\n",
"\n",
2024-11-23 20:14:21 +07:00
"num_games = len(Dat)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Questions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team wins"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 282,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that Blue Team wins: 0.4990383642069035\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Calculating the probability by diving the amount of games that blue won\n",
"# dividing it by the amount of total games\n",
"# Thus: p = Number of time an event occurs / Total nmumber of possible events\n",
"prob_blue_wins = len(Dat[Dat['blueWins'] == 1]) / num_games\n",
"print(\"Probability that Blue Team wins:\", prob_blue_wins)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team wins and kills the dragon"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 283,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that Blue Team wins and kills the dragon: 0.23200728818706348\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Doing a similar calculation with the difference being\n",
"# the number of time an event occurs now only counts\n",
"# the number of times blue team wins and kills the dragon\n",
"\n",
"prob_blue_wins_dragons = len(Dat[(Dat['blueWins'] == 1) & (Dat['blueDragons'] == 1)]) / num_games\n",
"print(\"Probability that Blue Team wins and kills the dragon:\", prob_blue_wins_dragons)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team wins and kills the herald"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 284,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that Blue Team wins and kills the herald: 0.11185342646016803\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Similar calculation but with the number of events that\n",
"# team blue wins and kills the herald\n",
"\n",
"prob_blue_wins_heralds = len(Dat[(Dat['blueWins'] == 1) & (Dat['blueHeralds'] == 1)]) / num_games\n",
"print(\"Probability that Blue Team wins and kills the herald:\", prob_blue_wins_heralds)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Count: All possible cases (Venn Diagram)"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 285,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZQAAAGFCAYAAADaTwWeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABMGklEQVR4nO3dd3gc9bn3//fM9qJVL1axbFnu2BgbbAPGYHpLc0IJ5EmcEwiHkEIKhJRfyCGFh5MQQnLSOISShEBwQs9DYmoAm2aCTXHBvVtdWml7md8fg2QLuajs7szs3q/r0mVLu5Zuectnvl3RNE1DCCGEGCPV6AKEEELkBwkUIYQQGSGBIoQQIiMkUIQQQmSEBIoQQoiMkEARQg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MAiPPaaf9S3yRiG2Sg4l6nTyiidJTMnfUHHanCysX8i0imlGl5KXJFCGq69PDxNZ/Z5XCrlVcigxp5NXvEnyb/7XYA2BBhY3Lsbn9BldSl6RQBmOcFgPk2DQ6EpEhmgKdNd7CTqltflBcYeDV31pwhZatDkaLpuLxY2LmVg60ehS8oYEytFEIvqYiUwNzhsJr4P2ccqITkUsNAmHg1e9aUJKfocKwLSKaZzUcJLMBMsACZQjiUb12VydnUZXIjKkr9pDpz86ptMRC0Xc4WClL5XXA/X9StwlnD7xdCq8FUaXYmkSKIcTj+th0t5udCUiA9KqQud4NyFbYQ+8j1TI7WaVO99HVHQ2xcapE06luazZ6FIsSwLlUBIJ+PvfobXV6EpEBqQcKm0
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Declaring variable for each set\n",
"# Loop through the whole games dataset and if the item-\n",
"# -matches the condition, add it to the set for that\n",
"# condition list\n",
"\n",
2024-11-23 23:23:18 +07:00
"game_blue_wins = set()\n",
"game_blue_dragon = set()\n",
"game_blue_herald = set()\n",
"\n",
2024-11-23 20:14:21 +07:00
"for game in range(num_games):\n",
" if(Dat['blueWins'][game] == 1):\n",
" game_blue_wins.add(game)\n",
2024-11-23 22:45:10 +07:00
" if(Dat['blueDragons'][game] == 1):\n",
" game_blue_dragon.add(game)\n",
2024-11-23 22:45:10 +07:00
" if(Dat['blueHeralds'][game] == 1):\n",
" game_blue_herald.add(game)\n",
"\n",
"venn3([game_blue_wins, game_blue_dragon, game_blue_herald], ('A', 'B', 'C'))\n",
"\n",
"plt.show()"
]
},
2024-11-23 20:14:21 +07:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Each possible events (Venn Diagram)"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 286,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"data": {
2024-11-23 23:34:06 +07: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sz8mIho1OhJhAA3oKvPQnm+u0dChJG021vrs7FGy62c24Aowo3wGE4snZlVro2wjCSlT1q3Tm6LKelFOChe5aC3UiFuxYECB7fle6tSQ0ZGkncvmYkrpFGaWz8RtdxsdjjiIJKR00zS9cOHjj42ORBgg6nfSVqIQyYIRRpvXwypnhIRJpxiHw2lzMrtiNjPKZmBTbUaHI/aRhJROyaRe0r1tm9GRiBEW9zpoK7cRUiNGh5JWYZeLtz1xYllR7tCbz+ljfuV8xhfJkR1mIAkpXWIxePFF/YhpkTOSLhtt5U46HdYvm+5PxOnkbU+CqJKdSQmgLK+MBVULZC+TwSQhpUMkAs8/D01NRkciRkjKrhIc5abDGTZt1Vw6RZ1O3vYmiGTpSGm/sQVjObrqaGnuahBJSMPV2aknIynrzgka0DHKS9AbSVtvOauIORy8k5ciRPaUhfdFVVSml03nyFFHyrEYI0wS0nAEg/Dcc3pSElkv7nXQXKESzYKChaGKOxy8401l1V6l/rjtbhaOWci4onFGh5IzJCENVWsrPPsshLN37UDoNKBjtJc2T25Mzx1Owm7n3TzoUHKjS31tYS2LqhdJmfgIkIQ0FMEgPPMMhLJvn4boSUZFfUvY7byXpxBUrLHhd7jcdjeLqhdRW1hrdChZTRLSYHV0wNNPQ1eX0ZGIDOuo8NCaZ95WP0ZL2my8l6/SZpEuFOkwvmg8i6oXydpShkhCGozOTn1k1NFhdCQig5IOleYqJ+Es21OUCUmbjdX5Ki05lJTynfmcOPZEOYspAyQhDVQopCejYNDoSEQGhQtdNBclSGZ
2024-11-23 23:23:18 +07:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Setting the variable for each section of the venn diagram\n",
"# Use these values to calculate its probability by\n",
"# diving with the total amount of games\n",
"# Produce venn diagram of the values\n",
"\n",
"count_a = 2055\n",
"count_b = 1096\n",
"count_c = 564\n",
"\n",
"count_ab = 1770\n",
"count_ac = 583\n",
"count_bc = 188\n",
"\n",
"count_abc = 522\n",
"\n",
2024-11-23 20:14:21 +07:00
"p_a = round(2055 / num_games, 3)\n",
"p_b = round(1096 / num_games, 3)\n",
"p_c = round(564 / num_games, 3)\n",
"\n",
2024-11-23 20:14:21 +07:00
"p_ab = round(1770 / num_games, 3)\n",
"p_ac = round(583 / num_games, 3)\n",
"p_bc = round(188 / num_games, 3)\n",
"\n",
2024-11-23 20:14:21 +07:00
"p_abc = round(522 / num_games, 3)\n",
"\n",
2024-11-23 23:23:18 +07:00
"plt.figure(figsize=(10, 5))\n",
"venn = venn3(subsets=(p_a, p_b, p_ab, p_c, p_ac, p_bc, p_abc), set_labels=('A', 'B', 'C'))\n",
"\n",
"plt.show()"
]
},
2024-11-23 20:14:21 +07:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team does not manage to do any of the events (Outer White Section)"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 287,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probabilty that Blue Team loses, doesn't kill dragons and heralds: 0.3138981678307521\n"
]
},
{
"data": {
2024-11-23 23:34:06 +07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGVCAYAAACxaoU9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABUYElEQVR4nO3deXxcdbn48c85s0+Syb60SUOS7ntLV9qKLGVtoYgIKMoicNH7u8K1KKIo7ooXBTcQRVlUEBHZwUIpIEILlJa1NN0XumXPZJl95vz+OG1omqTNNnPOmXner9e80kzOzDzTTM5zvtvzVTRN0xBCCCEMphodgBBCCIEkJCGEEGYhCUkIIYQpSEISQghhCpKQhBBCmIIkJCGEEKYgCUkIIYQpSEISQghhCpKQhBBCmIIkJCGEEKYgCU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nD8iONlW4wUk4Q0FH4/PPOMnpRE2ot6HTSVqYTTYMLCYEUdDt7wJtJqrVJf3HY3C0ctZHTBaKNDyRiSkAarpQWefhqC6Tt2IHQa0D7SS6snM7rnjiVmt/NmFrQrmVGlvia/hkWVi2SaeApIQhoMvx+eegoC6bdOQ3QnraLexex23spS8CvWWPA7VG67m0WVi6jJrzE6lLQmCWmg2tvhySehs9PoSESStZd5aMkyb6kfo8VtNt7KUWm1SBWK4TCmYAyLKhfJ2FKSSEIaiI4OvWXU3m50JCKJ4g6VpgonwTRbU5QMcZuN9TkqzRmUlHKcOZxSfYrsxZQEkpD6KxDQk5Hfb3QkIomC+S6aCmLE03wm2XB
2024-11-23 23:23:18 +07:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Calculate the total amount of the games in the venn diagram\n",
"# Find the complement of (A B C)\n",
"\n",
"count_all = count_a + count_b + count_c + count_ab + count_abc + count_ac + count_bc\n",
2024-11-23 23:23:18 +07:00
"did_not_win_all = num_games - count_all\n",
"prob_did_not_win_all = did_not_win_all / num_games\n",
"\n",
"print(\"Probabilty that Blue Team loses, doesn't kill dragons and heralds:\", prob_did_not_win_all)\n",
2024-11-23 20:14:21 +07:00
"\n",
2024-11-23 23:23:18 +07:00
"plt.figure(figsize=(10, 5))\n",
"venn = venn3(subsets=(p_a, p_b, p_ab, p_c, p_ac, p_bc, p_abc), set_labels=('A', 'B', 'C'))\n",
"\n",
2024-11-23 23:34:06 +07:00
"plt.text(0.5, -0.5, f'{round(prob_did_not_win_all, 3)}', ha='center', va='center')\n",
2024-11-23 23:23:18 +07:00
"plt.show()"
2024-11-23 20:14:21 +07:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team wins and kills dragon and herald"
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 288,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that blue team wins, kills dragon and herald: 0.053\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# The probability of this event is essentially the intersection of\n",
"# A (Blue Team Wins), B (Kills Dragon) and C (Kills Herald)\n",
"\n",
"print(\"Probability that blue team wins, kills dragon and herald:\", p_abc)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team does not win but kills dragon and the herald "
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 289,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that blue team does not win but kills dragon and the herald : 0.019\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Same with above but only with the intersection between\n",
"# B (Kills Dragon) and C (Kills Herald)\n",
"\n",
"print(\"Probability that blue team does not win but kills dragon and the herald :\", p_bc)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probability: Blue Team wins but does not kill dragon and herald. "
]
},
{
"cell_type": "code",
2024-11-23 23:34:06 +07:00
"execution_count": 290,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Probability that blue team wins without killing the dragon and the herald: 0.208\n"
]
}
],
"source": [
2024-11-23 20:14:21 +07:00
"# Same with above but only with the A section (Blue Team wins)\n",
"\n",
"print(\"Probability that blue team wins without killing the dragon and the herald:\", p_a)"
]
}
],
"metadata": {
"kernelspec": {
2024-11-23 23:23:18 +07:00
"display_name": "Python 3",
"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",
2024-11-23 23:23:18 +07:00
"version": "3.12.6"
}
},
"nbformat": 4,
2024-11-23 22:45:10 +07:00
"nbformat_minor": 4
}