Repository navigation
1. Probability
Probability quantifies how plausible outcomes are before seeing data.
Probability is about describing uncertainty consistently.
| View | Example | Mental Model |
|---|---|---|
| Frequentist | 40 defective parts in 1000 → 0.04 | Long‑run relative frequency |
| Bayesian | Before testing, defect rate believed 4% | Degree of belief, updated with evidence |
| Geometric/Measure | Dart hits within region of area ratio | Probability as normalized measure |
Probability isn’t “randomness,” it’s a language for incomplete information.
That is why we can’t say a single coin toss has a 50% “chance” of heads after seeing it. Because probability quantifies uncertainty before the outcome.
Purpose: compute uncertainty correctly before any inference.
An event E is a proposition, a statement, which we do not yet know whether it is true or false.
- Finetti
-
Sample space
$(\Omega)$ : all possible outcomes. -
Event
$(A \subseteq \Omega)$ : a set of outcomes whose probability we track. -
Intersection
$(A \cap B)$ : both happen; union$(A \cup B)$ : at least one happens; complement$(A^c)$ : does not happen.
-
Definition:
$(P(A,|,B) = \dfrac{P(A \cap B)}{P(B)})$ , for$(P(B)>0)$ . -
Independence:
$(A \perp B \iff P(A \cap B) = P(A),P(B) \iff P(A,|,B)=P(A))$ .
Use counts → proportions; avoid means on nominal codes (see Scales page).
import pandas as pd
# Intention: estimate P(Disease | Test = "pos") from a table of outcomes.
df = pd.DataFrame({
"test": ["pos","pos","neg","pos","neg","neg","pos","neg"],
"disease": [ True, False, False, True, False, False, True, False]
})
# Joint counts:
tab = pd.crosstab(df["disease"], df["test"]) # rows: disease; cols: test
# P(B) marginals (column proportions): P(test)
p_test = tab.sum(axis=0) / tab.values.sum()
# P(A|B): column-wise conditional P(disease | test)
p_dis_given_test = tab.div(tab.sum(axis=0), axis=1)
p_pos = p_test["pos"]
p_d_given_pos = p_dis_given_test.loc[True, "pos"]
print(f"P(test=pos) ≈ {p_pos:.3f}")
print(f"P(disease | test=pos) ≈ {p_d_given_pos:.3f}")- Name events precisely (membership in a category, threshold on a ratio variable).
- Pick the right denominator (condition first, then divide).
- For group comparisons, report both rates and base rates.
-
Collapsing categories arbitrarily → define a proper partition before using total probability.
-
Treating ordinal codes as interval → only order-based summaries should inform events (e.g., “≥ 4”).
-
Ignoring class imbalance → always show
$𝑃(𝐵)$ when reporting$P(A∣B)$ .
- Q1: A test has
$(P(\text{pos}|\text{disease})=0.9), (P(\text{pos}|\text{healthy})=0.1)$ . Disease prevalence$(P(\text{disease})=0.02). Compute (P(\text{disease}|\text{pos}))$ .
A1:$( \frac{0.9\cdot0.02}{0.9\cdot0.02 + 0.1\cdot0.98} \approx 0.155 )$ (15.5%). - Q2: If
$(P(A)=0.4), (P(B)=0.5), (P(A\cap B)=0.2)$ , are$(A)$ and$(B)$ independent?
A2: Yes,$(0.4\cdot0.5=0.2\Rightarrow)$ independent. - Q3: You report “80% of severe cases among seniors.” What denominator is correct for
$(P(\text{severe}|\text{senior}))$ ?
A3: Seniors only (condition first, then divide by seniors).
Legend:
- 🔰 Start here
- 🏵️ Important Insight
- ⚙️ Technical and applications
- 💻 Some Code
- ⚜️ Advanced Topics
- 00.1 What Is Data?
-
00.2 Three Models of Reality (planned)
- 00.2.1 The Linguistic
- 00.2.2 The Symbolic
- 00.3.3 The Mathematical
- 00.3 Maps and Reality
- 00.4 Aside: Hossack, data as structure
- 00.5 Aside: Chomsky, data as evidence
- 01.1 🔰 Sets and Logic (planned)
- 01.2 Sample Space
- 01.3 Randomness and Pattern
- 01.4 Outcomes and Events
- 01.5 Finite and Infinite Sample Spaces
- 02.1 🔰 Functions (planned)
- 02.2 Types Are Alphabets
- 02.3 Random Variables: X : Ω → 𝒳 (planned)
- 02.4 Measurement Scales
- 02.5 Numerics
- 03.1 🔰 Fractions and Proportions (planned)
- 03.2 Randomness vs Uncertainty
- 03.3 Probability: Events, Conditioning, Bayes
- 03.4 Bayes' Theorem, Step by Step
- 03.5 Expected Value and Variance (planned)
- 03.6 Bernoulli (ES)
- 03.7 Discrete Uniform (ES)
- 03.8 🧗 Kolmogorov: Ω, 𝒜, ℙ
- 04.1 🔰 Powers and Logarithms (planned)
- 04.2 Rarity
- 04.3 Information Theory (Shannon)
- 04.4 Entropy: Three Views
- 05.1 🔰 Sums and Averages (planned)
- 05.2 Data, Measured
- 05.3 Sampling (ES)
- 05.4 Population and Sample (ES)
- 05.5 Types of Sampling (ES)
- 05.6 Choosing Summaries & Visuals
- 05.7 Visualization
- 05.8 Plots
- 06.1 What Is Statistics?
- 06.2 🔰 Curves and Area (planned)
- 06.3 Statistical Thinking
- 06.4 Variation
- 06.5 Uncertainty
- 06.6 Parameters vs Estimators (ES)
- 06.7 Distributions
- 06.8 Statistical Modeling
- 06.9 Statistical Methods
- 07.1 Data Storage: Databases (stub)
- 07.2 ER Diagrams
- 07.3 Chen Diagrams
- 07.4 SQL (planned)
- 07.5 Formal Languages and Regular Expressions (planned)
- 07.6 Reproducibility (planned)
08 · μ(x) — Fuzzy - When data is flexible
- 08.1 Fuzzy Logic (planned)
- 08.2 Fuzzy Numbers (planned)
- 08.3 Possibility vs Probability (planned)
09 · x(t) — Signals and systems - Where patterns live
- 09.1 Signals (stub)
- 09.2 Sampling and Aliasing (planned)
- 09.3 Convolution (planned)
- 09.4 Frequency (planned)
- 10.1 🔰 Vectors and Matrices (planned)
- 10.2 Mathematical Modelling (planned)
- 11.1 🔰 Derivatives (planned)
- 11.2 Convex Optimisation (planned)
- 12.1 Supervised Learning (planned)
- 12.2 Data in Language Models
- 13.1 Cause and Effect (planned)
- 13.2 Capstone Guide (planned)