Lecture: Probability

The Science of Uncertainty

Basics • Rules • Independence • Counting

Today's Roadmap

1. Fundamentals

  • Equation: $f/N$
  • Properties (0 to 1)
  • Equally Likely vs Mutually Exclusive

2. The Rules

  • Addition ($A \cup B$)
  • Multiplication ($A \cap B$)
  • Conditional & Bayes Tree

3. Counting

  • Factors & Permutations
  • Combinations
  • Contingency Tables

Probability Basics

Formula (Equally Likely)

$P(E) = \frac{f}{N} = \frac{\text{Ways event can occur}}{\text{Total Possible Outcomes}}$

3 Key Properties

  • Range: $0 \le P(E) \le 1$
  • Impossible: $P=0$
  • Certain: $P=1$

Law of Large Numbers

Heads: 0
Tails: 0
Total: 0

P(Heads) ≈ --

Interactive: Three Coin Flip

Flip 3 Coins

Result: --

Sample Space ($2^3 = 8$)

HHHHHTHTHHTT
THHTHTTTHTTT

Each outcome is equally likely (1/8).

Interactive: Sample Space

Roll the Dice

Result: 1

Sample Space Visualization

Possible Outcomes ($N=6$):

Don't Confuse These!

1. Equally Likely Outcomes

Definition: Everyone has the same FAIR chance.

Example: A Balanced Coin.

🪙 $\approx$ 🪙
$P(H) = P(T) = 0.5$

2. Mutually Exclusive

Definition: Can NOT happen at the same time.

Example: Coin landing Heads AND Tails.

Overlap = 0

Events & Relationships

Definitions

Event ($E$): Subset of Sample Space.

Complement ($E^c$): Everything NOT in E.

$P(E^c) = 1 - P(E)$

Union ($\cup$): A OR B.

Intersection ($\cap$): A AND B.

Interactive Venn

AB

--

The Addition Rule (OR)

The "OR" means union.

$P(A \cup B) = P(A) + P(B) - P(A \cap B)$

Hover over the diagram to see the parts.

Overlap

Hover circles

We subtract the Overlap because it was added twice!

Multiplication (AND)

General Rule & Independence

$P(A \cap B) = P(A) \cdot P(B|A)$

Independent Events:

One event does not affect the other.

$P(B|A) = P(B)$

Therefore: $P(A \cap B) = P(A) \cdot P(B)$

Interactive Tree

Click circles to reveal probability math.

P(A)=0.6P(A')=0.4P(B|A)=0.5Start × Branch =P(A and B) = 0.3

Bayes' Rule

Updating probability of a "Cause" given an "Effect".

$P(\text{Sick}|\text{Positive}) = \frac{P(\text{Sick})P(\text{Pos}|\text{Sick})}{P(\text{Pos})}$

Text Explanation

Numerator: True Positives

Count of Sick people who test positive.

Denominator (Total)

Numerator + False Positives

(Sick & Pos) + (Healthy & Pos)

Bayes' Rule Deconstructed

$P(A|B)$
Probability A Will Happen
Given Evidence B
$=$
$P(B|A)$
Probability B Will Happen
Given Evidence A
$\cdot$$P(A)$
Probability A Will Happen
$P(B)$
Probability B Will Happen
Key Insight: We are "flipping" the conditional probability. We know $P(B|A)$(Effect given Cause), but we want to know $P(A|B)$ (Cause given Effect).

Interactive: The Medical Test

Scenario

Population: 100 Dots.
Sick (Red): 10% (10 dots).
False Positives: 10% of Healthy (9 dots).
True Positives: 100% of Sick (10 dots).


IF you test positive (Yellow Halo), are you sick?

--

Formula: $\frac{TP}{TP + FP}$

Counting Techniques

1. Basic Rule (BCR)

Multiply options.

$n_1 \cdot n_2 \cdot n_3...$

2. Permutations

Order MATTERS

Books on Shelf

$\frac{n!}{(n-r)!}$

3. Combinations

Order IRRELEVANT

Committees

$\frac{n!}{r!(n-r)!}$

Interactive: Picker

Pick 3 chars from A-Z (26 options)

[_] [_] [_]

The Math

--

Select a mode & Pick

R for Counting & Probability

1. Factorials & Combinations


# Factorial: 5!
factorial(5)  # 120

# Combinations nCr: (10 choose 3)
choose(10, 3) # 120

# Permutations nPr:
factorial(10) / factorial(10 - 3)
                        

2. Sampling & Probability


# Sample Space (e.g., Coin)
outcomes <- c("H", "T")

# Draw 10 samples with replacement
sample(outcomes, size=10, replace=TRUE)

# Simulate 5! (Permutation)
prod(5:1)
                        

Contingency Tables

Organizing data by two categorical variables.

  • Joint Prob: Cell / Total
  • Marginal Prob: Row or Col Total / Total
  • Conditional: Cell / Row Total

Real World Example: Work Shifts

InternJuniorSeniorExpertTotal
Morning515201050
Afternoon102015550
Night251051050
Total40454025150

Calculations

1. P(Intern): (Marginal)
$40 / 150 = 0.27$

3. P(Senior | Morning): (Conditional)

Given "Morning", look ONLY at top row.

$20 / 50 = 0.40$

Questions?

Next: Discrete Probability Distributions