{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "206bf674", "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", "\n", "sns.set_theme(style=\"whitegrid\", context=\"notebook\")" ] }, { "cell_type": "markdown", "id": "612bd02c", "metadata": {}, "source": [ "# Chapter 1 Summary Notes" ] }, { "cell_type": "markdown", "id": "be70f5df", "metadata": {}, "source": [ "## Intro (1.0.0 - 1.3.1)\n", "\n", "**Theorem 1.1: De Morgan's law** \\\n", "For any sets $A_1, A_2, A_3, \\dots A_n$, we have\n", "- $(A_1 \\cup A_2 \\cup A_3 \\cup \\dots A_n)^c = A_1^c \\cap A_2^c \\cap A_3^c \\cap \\dots A_n^c$\n", "- $(A_1 \\cap A_2 \\cap A_3 \\cap \\dots A_n)^c = A_1^c \\cup A_2^c \\cup A_3^c \\cup \\dots A_n^c$\n", "\n", "**Theorem 1.2: Distributive law** \\\n", "For any sets $A, B,$ and $C$ we have\n", "- $A \\cap (B \\cup C) = (A \\cap B)\\cup(A \\cap C)$\n", "- $A \\cup (B \\cap C) = (A \\cup B)\\cap(A \\cup C)$\n", "\n", "**Inclusion-exclusion principle** \\\n", "For a finite collection of sets $A_1, A_2, A_3, \\dots A_n$, we have\n", "\n", "$\\left| \\bigcup_{i=1}^n A_i \\right| = \\sum_{i=1}^n |A_i| - \\sum_{i < j} |A_i \\cap A_j| + \\sum_{i < j < k} |A_i \\cap A_j \\cap A_k| - \\dots + (-1)^{n-1} |A_1 \\cap A_2 \\cap \\dots \\cap A_n|$\n", "\n", "$n = 2$ case:\n", "\n", "$|A \\cup B| = |A| + |B| - |A \\cap B|$\n", "\n", "$n = 3$ case:\n", "\n", "$|A \\cup B \\cup C| = |A| + |B| + |C| - |A \\cap B| - |A \\cap C| - |B \\cap C| + |A \\cap B \\cap C|$\n", "\n" ] }, { "cell_type": "markdown", "id": "c7475d4f", "metadata": {}, "source": [ "## Random experiments (1.3.1 - 1.4)\n", "\n", "- A **random experiment** is a process by which we observe something uncertain\n", "- An **outcome** is a result of a random experiment\n", "- The **sample space** $S$ is the set of all possible outcomes\n", "- An **event** $A$ is any subset of $S$\n", "\n", "> In the context of a random experiment, the sample space is our *universal set*\n", "\n", "**Axioms of Probability**\n", "\n", "1. For any event $A$, $P(A) \\geq 0$\n", "2. $P(S) = 1$\n", "3. If $A_1, A_2, A_3, \\dots$ are disjoint events, then $P(A_1 \\cup A_2 \\cup A_3 \\cup \\dots) = P(A_1) + P(A_2) + P(A_3) + \\dots$\n", "\n", "**Some notation**\n", "\n", "- $P(A \\cap B) = P(A$ and $B) = P(A,B)$\n", "- $P(A \\cup B) = P(A$ or $B)$\n", "\n", "In a finite sample space $S$, where all outcomes are equally likely, the probability of any event $A$ can be found by\n", "\n", "\\begin{align*}\n", "P(A) = \\frac{|A|}{|S|}\n", "\\end{align*}" ] }, { "cell_type": "markdown", "id": "b705ef32", "metadata": {}, "source": [ "## Conditional probability (1.4.0)\n", "\n", "If $A$ and $B$ are twos events in sample space $S$, then the **conditional probability of $A$ given $B$** is defined as\n", "\n", "\\begin{align*}\n", "P(A|B) = \\frac{P(A \\cap B)}{P(B)}, \\text{when } P(B) > 0\n", "\\end{align*}\n", "\n", "or\n", "\n", "\\begin{align*}\n", "P(A|B) = \\frac{|A \\cap B|}{|B|}, \\text{when } P(B) > 0\n", "\\end{align*}\n", "\n", "For events $A, B,$ and $C$, with $P(C) \\gt 0$, we have\n", "\n", "- $P(A^c|C) = 1 - P(A|C)$\n", "- $P(\\empty|C) = 0$\n", "- $P(A|C) \\leq 1$\n", "- $P(A \\setminus B|C) = P(A|C) - P(A \\cap B|C)$\n", "- $P(A \\cup B|C) = P(A|C) + P(B|C) - P(A \\cap B|C)$\n", "- if $A \\subset B$ then $P(A|C) \\leq P(B|C)$\n", "\n", "![](../public/conditional_prob_tree.png)" ] }, { "cell_type": "markdown", "id": "188a8fc2", "metadata": {}, "source": [ "## Independence (1.4.1)\n", "\n", "**Definition.** Two events $A$ and $B$ are *independent* if $P(A \\cap B) = P(A)P(B)$. AKA $P(A|B) = P(A)$\n", "\n", "**Definition.** Three events $A, B,$ and $C$ are independent if **all** of the following conditions hold:\n", "- $P(A \\cap B) = P(A)P(B)$\n", "- $P(A \\cap C) = P(A)P(C)$\n", "- $P(B \\cap C) = P(B)P(C)$\n", "- $P(A \\cap B \\cap C) = P(A)P(B)P(C)$\n", "\n", "**Definition.** $N$ events $A_1, A_2, A_3, \\dots, A_n$ are independent if **all** the following conditions holds:\n", "- $P(A_i \\cap B_j) = P(A_i)P(A_j)$\n", "- $P(A_i \\cap A_j \\cap A_k) = P(A_i)P(A_j)P(A_k)$ where $i \\in [1:n+1]$, $j \\in [i:n+1]$, $k \\in [j:n+1]$\n", "- $\\dots$\n", "- $P(A_1 \\cap A_2 \\cap A_3 \\cap \\dots \\cap A_n) = \\prod_{i=1}^nP(A_i)$\n", "\n", "**Lemma.** \\\n", "If $A$ and $B$ are independent then\n", "- $A$ and $B^c$ are independent\n", "- $A^c$ and $B$ are independent\n", "- $A^c$ and $B^c$ are independent\n", "\n", "**Definition.** If $A_1, A_2, \\dots, A_n$ are independent then\n", "$$P(A_1 \\cup A_2 \\cup \\dots \\cup A_n) = 1 - (1 - P(A_1))(1 - P(A_2))\\dots(1 - P(A_n))$$" ] }, { "cell_type": "markdown", "id": "90cf5b00", "metadata": {}, "source": [ "## Law of Total Probability (1.4.2)\n", "\n", "$$P(A) = P(A|B)P(B) + P(A|B^c)P(B^c)$$\n", "\n", "**Definition.** Law of Total Probability: \\\n", "If $B_1, B_2, B_3, \\dots $ is a partition of the sample space $S$, then for any event $A$ we have\n", "\n", "$$P(A) = \\sum_i P(A \\cap B_i) = \\sum_i P(A|B_i)P(B_i)$$" ] }, { "cell_type": "markdown", "id": "c33df800", "metadata": {}, "source": [ "## Bayes' Rule (1.4.3)\n", "\n", "**Definition.** Bayes' Rule\n", "\n", "- For any two events $A$ and $B$, where $P(A) \\neq 0$, we have\n", "\n", "$$P(B|A) = \\frac{P(A|B)P(B)}{P(A)}$$\n", "\n", "- If $B_1, B_2, B_3, \\dots$ form a partition of the sample space $S$, and $A$ is any event with $P(A) \\neq 0$, we have\n", "\n", "$$P(B_j|A) = \\frac{P(A|B_j)P(B_j)}{\\sum_i P(A|B_i)P(B_i)}$$" ] }, { "cell_type": "markdown", "id": "849d7c99", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "roadmap (3.14.5)", "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.14.5" } }, "nbformat": 4, "nbformat_minor": 5 }