diff --git a/fall-2024/math/mat-203/00020/.~lock.mat-203-00020.odt# b/fall-2024/math/mat-203/00020/.~lock.mat-203-00020.odt# deleted file mode 100644 index bd69e9f..0000000 --- a/fall-2024/math/mat-203/00020/.~lock.mat-203-00020.odt# +++ /dev/null @@ -1 +0,0 @@ -,slimbook,wins-slimbook,23.11.2024 10:25,file:///home/slimbook/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4; \ No newline at end of file diff --git a/fall-2024/math/mat-203/00020/MAT-203 - 00020 - Thanawin Pattanaphol.pdf b/fall-2024/math/mat-203/00020/MAT-203 - 00020 - Thanawin Pattanaphol.pdf index 792b472..292be4e 100644 Binary files a/fall-2024/math/mat-203/00020/MAT-203 - 00020 - Thanawin Pattanaphol.pdf and b/fall-2024/math/mat-203/00020/MAT-203 - 00020 - Thanawin Pattanaphol.pdf differ diff --git a/fall-2024/math/mat-203/00020/mat-203-00020.odt b/fall-2024/math/mat-203/00020/mat-203-00020.odt index a3ee86f..c0f1b79 100644 Binary files a/fall-2024/math/mat-203/00020/mat-203-00020.odt and b/fall-2024/math/mat-203/00020/mat-203-00020.odt differ diff --git a/fall-2024/math/mat-204/00010/.~lock.mat-204-00010 - probability.odt# b/fall-2024/math/mat-204/00010/.~lock.mat-204-00010 - probability.odt# new file mode 100644 index 0000000..140582b --- /dev/null +++ b/fall-2024/math/mat-204/00010/.~lock.mat-204-00010 - probability.odt# @@ -0,0 +1 @@ +,winsdominoes,fedora,23.11.2024 20:14,file:///home/winsdominoes/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4; \ No newline at end of file diff --git a/fall-2024/math/mat-204/00010/.~lock.mat-204-00020 - probability.odt# b/fall-2024/math/mat-204/00010/.~lock.mat-204-00020 - probability.odt# deleted file mode 100644 index e6d5669..0000000 --- a/fall-2024/math/mat-204/00010/.~lock.mat-204-00020 - probability.odt# +++ /dev/null @@ -1 +0,0 @@ -,slimbook,wins-slimbook,23.11.2024 10:26,file:///home/slimbook/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4; \ No newline at end of file diff --git a/fall-2024/math/mat-204/00010/mat-204-00010 - probability.odt b/fall-2024/math/mat-204/00010/mat-204-00010 - probability.odt new file mode 100644 index 0000000..36050e6 Binary files /dev/null and b/fall-2024/math/mat-204/00010/mat-204-00010 - probability.odt differ diff --git a/fall-2024/math/mat-204/00010/mat-204-00020 - probability.odt b/fall-2024/math/mat-204/00010/mat-204-00020 - probability.odt deleted file mode 100644 index c15ba71..0000000 Binary files a/fall-2024/math/mat-204/00010/mat-204-00020 - probability.odt and /dev/null differ diff --git a/fall-2024/math/mat-204/Game.ipynb b/fall-2024/math/mat-204/Game.ipynb index 5fd66f1..21399be 100644 --- a/fall-2024/math/mat-204/Game.ipynb +++ b/fall-2024/math/mat-204/Game.ipynb @@ -1,8 +1,23 @@ { "cells": [ + { + "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", - "execution_count": 50, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -12,12 +27,26 @@ "\n", "Dat = pd.read_csv('DataLoL.csv')\n", "\n", - "nGame = len(Dat)" + "num_games = len(Dat)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Questions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Probability: Blue Team wins" ] }, { "cell_type": "code", - "execution_count": 51, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -29,13 +58,23 @@ } ], "source": [ - "ProbBlueWins = len(Dat[Dat['blueWins'] == 1]) / nGame\n", - "print(\"Probability that Blue Team wins is: \", ProbBlueWins)" + "# 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", - "execution_count": 52, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -47,13 +86,24 @@ } ], "source": [ - "ProbBlueWinsAndDragon = len(Dat[(Dat['blueWins'] == 1) & (Dat['blueDragons'] == 1)]) / nGame\n", - "print(\"Probability that Blue Team wins and kills the dragon is: \", ProbBlueWinsAndDragon)" + "# 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", - "execution_count": 53, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -65,13 +115,23 @@ } ], "source": [ - "ProbBlueWinsAndHerald = len(Dat[(Dat['blueWins'] == 1) & (Dat['blueHeralds'] == 1)]) / nGame\n", - "print(\"Probability that Blue Team wins and kills the herald is: \", ProbBlueWinsAndHerald)" + "# 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", - "execution_count": 54, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -86,16 +146,19 @@ } ], "source": [ - "game_blue_wins = set()\n", - "game_blue_dragon = set()\n", - "game_blue_herald = set()\n", + "# 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", - "for game in range(nGame):\n", + "game_blue_wins, game_blue_dragon, game_blue_herald = set()\n", + "\n", + "for game in range(num_games):\n", " if(Dat['blueWins'][game] == 1):\n", " game_blue_wins.add(game)\n", - " if(Dat['blueDragons'][game] == 1):\n", + " else if(Dat['blueDragons'][game] == 1):\n", " game_blue_dragon.add(game)\n", - " if(Dat['blueHeralds'][game] == 1):\n", + " else 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", @@ -103,9 +166,16 @@ "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Probability: Each possible events (Venn Diagram)" + ] + }, { "cell_type": "code", - "execution_count": 55, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -120,6 +190,11 @@ } ], "source": [ + "# 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", @@ -130,22 +205,29 @@ "\n", "count_abc = 522\n", "\n", - "p_a = round(2055 / nGame, 3)\n", - "p_b = round(1096 / nGame, 3)\n", - "p_c = round(564 / nGame, 3)\n", + "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", - "p_ab = round(1770 / nGame, 3)\n", - "p_ac = round(583 / nGame, 3)\n", - "p_bc = round(188 / nGame, 3)\n", + "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", - "p_abc = round(522 / nGame, 3)\n", + "p_abc = round(522 / num_games, 3)\n", "\n", "venn = venn3(subsets=(p_a, p_b, p_ab, p_c, p_ac, p_bc, p_abc), set_labels=('A', 'B', 'C'))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Probability: Blue Team does not manage to do any of the events (Outer White Section)" + ] + }, { "cell_type": "code", - "execution_count": 56, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -157,12 +239,25 @@ } ], "source": [ - "print(\"Probabilty that Blue Team loses, doesn't kill dragons and heralds: \", (nGame - (count_a + count_b + count_c + count_ab + count_abc + count_ac + count_bc)) / nGame)" + "# 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", + "did_not_win_all = num_games - p_all_wins\n", + "\n", + "print(\"Probabilty that Blue Team loses, doesn't kill dragons and heralds:\", did_not_win_all / num_games)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Probability: Blue Team wins and kills dragon and herald" ] }, { "cell_type": "code", - "execution_count": 57, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -174,12 +269,22 @@ } ], "source": [ - "print(\"Probability that blue team wins, kills dragon and herald: \", p_abc)" + "# 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", - "execution_count": 58, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -191,12 +296,22 @@ } ], "source": [ - "print(\"Probability that blue team kills dragon and the herald but does not win: \", p_bc)" + "# 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", - "execution_count": 59, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -208,7 +323,9 @@ } ], "source": [ - "print(\"Probability that blue team wins without killing the graon and the herald: \", p_a)" + "# 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)" ] } ], @@ -228,7 +345,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.6" + "version": "3.11.2" } }, "nbformat": 4,