140 lines
4.5 KiB
Plaintext
140 lines
4.5 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "c58309b2",
|
|
"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": "a6732353-51d5-4478-9cf8-5834e57e5a4e",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Chapter 2 Notes"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9f0046c2",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Counting (2.0.0 - 2.1.5)\n",
|
|
"\n",
|
|
"***Definition.*** Multiplication Principle: \\\n",
|
|
"Suppose that we perform $r$ experiments such that the $k\\text{th}$ experiment has $n_k$ possible outcomes, for $k=1,2,\\dots,r$. Then there are a total of $n_1 \\times n_2 \\times n_3 \\times \\dots \\times n_r$ possible outcomes for the sequence of $r$ experiments\n",
|
|
"\n",
|
|
"### Terminology\n",
|
|
"\n",
|
|
"- **Sampling**: Sampling from a set means choosing an element from that set. We\n",
|
|
"often **draw** a sample at random from a given set in which each element of the\n",
|
|
"set has equal chance of being chosen\n",
|
|
"\n",
|
|
"- **With or without replacement**: Usually we draw multiple samples from a set. If\n",
|
|
"we put each object back after each draw, we call this sampling with\n",
|
|
"replacement. In this case a single object can be possibly chosen multiple times.\n",
|
|
"For example, if A = {a1, a2, a3, a4} and we pick 3 elements with replacement, a\n",
|
|
"possible choice might be (a3, a1, a3). Thus \"with replacement\" means \"repetition\n",
|
|
"is allowed.\" On the other hand, if repetition is not allowed, we call it sampling\n",
|
|
"without replacement\n",
|
|
"\n",
|
|
"- **Ordered or unordered**: If ordering matters (i.e.: a1, a2, a3 ≠ a2, a3, a1), this is\n",
|
|
"called ordered sampling. Otherwise, it is called unordered\n",
|
|
"\n",
|
|
"### Counting Formulas\n",
|
|
"\n",
|
|
"- **ordered sampling with replacement:** $n^k$\n",
|
|
"\n",
|
|
"- **ordered sampling without replacement:** $n$ permute $k$ $\\quad$ ie $P^n_k = \\frac{n!}{(n - k)!}$\n",
|
|
"\n",
|
|
"- **unordered sampling without replacement:** $n$ choose $k$ $\\quad$ ie $\\binom{n}{k} = \\frac{n!}{k!(n-k)!}$\n",
|
|
"\n",
|
|
"- **unordered sampling with replacement:** $\\binom{n + k - 1}{k}$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2e93e0fe",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Problem Solving Principles"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "87279e59",
|
|
"metadata": {},
|
|
"source": [
|
|
"When solving a combinatorics problem, consider:\n",
|
|
"1. Does order matter?\n",
|
|
" - Yes → Permutations\n",
|
|
" - No → Combinations\n",
|
|
"\n",
|
|
" - \"Are HHHTT and THHHT the same outcome to me?\"\n",
|
|
"\n",
|
|
"2. Are we sampling with of without replacement?\n",
|
|
" - Without replacement → Hypergeometric (phone problem)\n",
|
|
" - With replacement → Binomial (coin flips)\n",
|
|
" \n",
|
|
" \"Can the same item be chosen twice?\"\n",
|
|
"3. Are the \"groups\" labeled or unlabeled?\n",
|
|
" - Labeled/distinguishable → Just multiply combinations\n",
|
|
" - Unlabeled/interchangeable → Divide by k!\n",
|
|
"\n",
|
|
" \"Does it matter which group is called group 1?\"\n",
|
|
"4. Are the items distinguishable?\n",
|
|
" - Distinguishable → Each item is unique, classical probability applies\n",
|
|
" - Indistinguishable → Outcomes are not equally likely, be careful\n",
|
|
"\n",
|
|
" \"Could I label these items 1 to n?\"\n",
|
|
"5. Is complement of inclusion-exclusion easier?\n",
|
|
" - Complement → When \"at least\" or \"at most\" language appears\n",
|
|
" - Inclusion-Exclusion → When events overlap\n",
|
|
"\n",
|
|
" \"Is the opposite event simpler to count?\"\n",
|
|
"6. Am I counting each outcome exactly once? \n",
|
|
" - If yes, done. Otherwhise we are overcounting or undercounting"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9c5783dc",
|
|
"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
|
|
}
|