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

377 lines
94 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:23:18 +07:00
"execution_count": 229,
"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:23:18 +07:00
"execution_count": 230,
"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:23:18 +07:00
"execution_count": 231,
"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:23:18 +07:00
"execution_count": 232,
"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:23:18 +07:00
"execution_count": 233,
"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:23:18 +07:00
"execution_count": 234,
"metadata": {},
2024-11-23 23:23:18 +07:00
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgo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QmBpfrcxDCZlMrHGZ2aMk1ns2zZbG2LyxDMsallDlA4V+JHnGytq1kYLuMr6ZlLyZNuoyNAJGnIyjwLZUJ2WqR+9Ios5msjEyZyTj8sZhN9v1DkcYmCTPaNO0yKSgb77ROxKhg1a3lfpsBV8CtNzqnQ5WWn0E47SbuS+sJisT8icwNncsJtWkdzjCgCR5RlMoFFmGUl6udySinwWcFurzTHhUn96hRJXXZmOZI4A/IaYSdeSyuphSMIUhmbKNm+gZSZ7R4vfD22/Dnj16RyL6Uchmoj7PSrPF+Es9uuKzWlnmCNKqJGYCBchNyWVa4TRZKyq6TZJnNPh88OabUF2tdySin4TNKg0D7DRZvXE7ezaaWq1WljmD+BK0BbrfoPRBTC2cKoXpxWFJ8uyr5uZI4pSlKElBA5oGOGlw+qJWa9Yo/BYLn6eE8ZA4S1k6oyoqY3LHcOSAI2WrNNElSZ590dAAb7wRSaAi4QWcFmryVVoTYDJQbwUsFj53hhNqLWhX7GY7M4tmMjhzsN6hiDgkybO36urg9dfBm7hjXSJCA5oGOql3JEcX7eEEzWaWp0CTkhy7AZVmlDKreJYsbRHtSPLsjYYGeO018CTeOjjRnrQ2Oxc0m/kiRaFBMUbxh76ym+3MKp5FaUap3qGIOCHJs6eamuDVV6GlRe9IRIw15TuoS4nfcnp6C5lMfJGqUm+Q6knRMCRzCLOKZ8lYqJDk2SPNzZEWZ1OT3pGIGApZVGoKrXgTbM1mLIR
"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.text(0.6, -0.5, f'Complement: aaaaa', ha='center', va='center')\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:23:18 +07:00
"execution_count": 240,
"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": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAGVCAYAAACxaoU9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABUW0lEQVR4nO3deXxcdbn48c85s0+Syb60SUOT7ntLV9qKLGVtoYgIKMoicNH7u8K1KKIo7ooXBTcQRVlUEBHZwUIpIEILlJa1NN0XumXPZJl95vz+OG1o2qTNMjPnnJnn/XrNK83kzMwzzeQ857s9X0XTNA0hhBDCYKrRAQghhBBIQhJCCGEWkpCEEEKYgiQkIYQQpiAJSQghhClIQhJCCGEKkpCEEEKYgiQkIYQQpiAJSQghhClIQhJCCGEKkpCEEEKYgiQkIYQQpiAJSQghhClIQhJCCGEKkpC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LjRb0OmitUwhkwYWGwog4Hb3gTGbVWqS9uu5sFIxYwqmiU0aFkDUlIg9XaCk8/DcHMHTsQOg3oGO6lzZMd3XPHErPbeTMHOpTsqFJfW1jLwuqFMk08DSQhDYbfD089BYHMW6chepJWUe9idjtv5Sj4FWss+B0qt93NwuqF1BbWGh1KRpOENFAdHfDkk9DVZXQkIsU6Kjy05pi31I/R4jYbb+WptFmkCkUyjC4azcLqhTK2lCKSkAais1NvGXV0GB2JSKG4Q6W5ykkww9YUpULcZmNdnkpLFiWlPGcep9ScInsxpYAkpP4KBPRk5PcbHYlIoWChi+aiGPEMn0mWTAl
"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",
"plt.text(0.6, -0.5, f'{round(prob_did_not_win_all, 3)}', ha='center', va='center')\n",
"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:23:18 +07:00
"execution_count": 236,
"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:23:18 +07:00
"execution_count": 237,
"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:23:18 +07:00
"execution_count": 238,
"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
}