← → / SPACE to navigate
LECTURE 02 · PROBABILITY FOR RL

The math we'll need:
probability.

Last time we drew the agent–environment loop. Today we build the toolkit we'll use to formalize it next time — outcomes, random variables, expectation, conditional probability, ending with a tiny game that bridges from L1's bandit to next week's MDP.

🎲 Outcomes & events 🎯 Random variables 📈 Expectation 🔀 Conditional & Bayes
Title
01 / 20
LAST TIME · LECTURE 01 RECAP

Where we left off.

Four ideas from last week — the picture, before we add the math today.

01

Supervised = answer key.

Many labeled examples, minimize the error. Powers most AI you use today — spam filters, photo tagging, translation.

02

RL = trial & reward.

No labels. The policy reads the current state to choose an action; that action plus the state drives where you land next, and the environment feeds back a reward.

state → policy → action · state + action → next state · env → reward
03

Explore vs exploit.

Every learner — even you in the 3-box game — must balance trying new things against using what already works.

04

RL can surpass humans.

AlphaGo's Move 37 wasn't taught — it was discovered through self-play. RL invents strategies no teacher knows.

L1 Review
02 / 20
PROBABILITY PRIMER · 1 OF 4

Three pieces, before anything random happens.

Before we can talk about random variables, we need to fix the playground. Every probability problem rests on three things: outcomes, events, and a probability rule.

SAMPLE SPACE
\(\Omega\)

The set of all possible outcomes of one trial. A single outcome is called \(\omega\). Outcomes need not be numbers — they can be abstract labels like heads or tails. (Some books write \(S\) instead of \(\Omega\) — same idea.)

🪙 Coin: \(\Omega=\{H,T\}\)
🎲 Die: \(\Omega=\{1,2,3,4,5,6\}\)
EVENT
\(A\)

A collection of outcomes from \(\Omega\) — anything you might ask about. (Braces matter: \(\{H\}\) is the event "got heads.")

🪙 "Heads" = \(\{H\}\)
🎲 "Even" = \(\{2,4,6\}\)
PROBABILITY
\(P(A) \in [0,1]\)

A function of events. Rules: \(P(\Omega)=1\); and \(P(A\cup B)=P(A)+P(B)\) when \(A,B\) are disjoint. A handy consequence — the complement: \(P(A^c)=1-P(A)\).

🪙 Fair: \(P(\{H\})=\tfrac{1}{2}\)
🎲 Fair: \(P(\{2,4,6\})=\tfrac{3}{6}\)

† Math name: such a function of the events is called a (probability) measure.

Outcomes & Events
03 / 20
PROBABILITY PRIMER · 2 OF 4

From outcomes to numbers: the random variable.

Try this question: "In 100 coin flips, how many heads will I see?" Outcomes like H and T aren't numbers — you can't add them, average them, or plot them. Most real sample spaces are like this — weather conditions, cards drawn, songs played. So we build a tiny bridge: assign a number to every outcome, and the messy world becomes calculable.

\[ X : \Omega \to \mathbb{R} \]
A random variable \(X\) is a function. For each outcome \(\omega \in \Omega\), it hands back a number \(X(\omega)\).
DEFINE X · "NUMBER OF HEADS"
\(X(H) = 1, \quad X(T) = 0\)

One number per outcome — that's the whole job of \(X\). Here it encodes a yes/no question: "did we see a head?"

WRITE THE EVENT AS MATH

Over 5 flips let \(X_i = 1\) if flip \(i\) is heads, else \(0\). Turn each English event into a condition on the \(X_i\).

Q1 · WORKED EXAMPLE

Event: exactly 2 heads in 5 flips.

\(\sum_{i=1}^{5} X_i = 2\)

The head count is \(X_1+\cdots+X_5\); "exactly 2 heads" pins that sum to 2.

Q2 · YOUR TURN

Event: at least one head in 5 flips. Write it.

\(\sum_{i=1}^{5} X_i \ge 1\)

"At least one" means the head count is 1 or more.

tap to reveal
Q3 · YOUR TURN

Event: more heads than tails in 5 flips. Write it.

\(\sum_{i=1}^{5} X_i \ge 3\)

With 5 flips, "more heads than tails" needs at least 3 heads.

tap to reveal

Once events are conditions on numbers, we can ask how likely each value is — and what value to expect on average. Next slide.

Random Variable
04 / 20
PROBABILITY PRIMER · 3 OF 4

How likely — and what to expect.

Once \(X\) is a random variable, two questions follow: how often does it take each value, and what value should we expect on average?

DISTRIBUTION
\[ p_X(x) = P(X = x) \]

For each possible value \(x\), the chance that \(X\) equals it. The whole list sums to 1.

🎲 Fair die: \(p_X(k) = \tfrac{1}{6}\) for \(k = 1,\ldots,6\)
EXPECTATION
\[ \mathbb{E}[X] = \sum_x x \cdot p_X(x) \]

A weighted average of the values — each value \(x\) weighted by its probability \(p_X(x)\). More-probable values pull the average toward them. There's no notion of time here — it's just a sum. (How this connects to real repeated trials → next slide.)

🎲 Die: \(\mathbb{E}[X] = 1{\cdot}\tfrac{1}{6} + 2{\cdot}\tfrac{1}{6} + \cdots + 6{\cdot}\tfrac{1}{6} = \tfrac{21}{6} = 3.5\)

Why we care: RL agents maximize \(\mathbb{E}[G_t]\) — the expected total reward, not any single outcome. The symbol \(\mathbb{E}\) will show up in nearly every formula from here on.

Distribution & Expectation
05 / 20
WHAT PROBABILITY MEANS

Frequency becomes probability.

We keep writing \(P(H)=\tfrac12\) — but what does that number mean? Flip a coin \(n\) times and track the frequency of heads. As \(n\) grows, that fraction stops wandering and settles onto the probability.

FREQUENCY · what you observe
\[ \hat{p}_n = \frac{\#\,\text{heads in } n \text{ flips}}{n} \]

The empirical fraction — it changes with every flip.

PROBABILITY · what it converges to
\[ \hat{p}_n \;\longrightarrow\; p=\tfrac12 \quad (n\to\infty) \]

The fixed value the frequency settles on — the law of large numbers. It's why a weighted average (expectation) predicts real performance.

† Law of large numbers — Jacob Bernoulli, Ars Conjectandi (1713); strong form: Borel (1909), Kolmogorov (1933).

0flips
0heads
frequency
Frequency & Probability
06 / 20
WHAT EXPECTATION MEANS

The average settles on \(\mathbb{E}[X]\).

We computed \(\mathbb{E}[X]=3.5\) for a fair die as a weighted average. Now roll it for real: the empirical mean of the numbers you roll converges to that very value.

EMPIRICAL MEAN · what you observe
\[ \bar{X}_n = \frac{X_1 + \cdots + X_n}{n} \]

The running average of the numbers you actually rolled — it jumps around at first.

EXPECTATION · what it converges to
\[ \bar{X}_n \;\longrightarrow\; \mathbb{E}[X]=3.5 \quad (n\to\infty) \]

The weighted average from the last slide, now confirmed by experiment. This is why RL can optimize \(\mathbb{E}\).

† Law of large numbers — Jacob Bernoulli, Ars Conjectandi (1713); strong form: Borel (1909), Kolmogorov (1933).

0rolls
0sum
mean
Mean & Expectation
07 / 20
PROBABILITY PRIMER · 4 OF 4

When new info changes the odds.

Probabilities update when you learn something. If I tell you it's cloudy outside, your guess that it'll rain rises. We write the updated probability as \(P(A \mid B)\) — read aloud "probability of \(A\) given \(B\)."

\[ P(A \mid B) = \frac{P(A \cap B)}{P(B)} \]
\(P(A \cap B)\) is the chance that both \(A\) and \(B\) happen. So: of all the times \(B\) happens, what fraction also have \(A\)? (We need \(P(B) > 0\).)
CARDS · A WORKED EXAMPLE
\(A\) = "King" \(\to P(A) = \tfrac{4}{52}\)
\(B\) = "face card" \(\to P(B) = \tfrac{12}{52}\)
All Kings are face cards: \(P(A \cap B) = \tfrac{4}{52}\)
\(P(A \mid B) = \dfrac{4/52}{12/52} = \tfrac{1}{3}\)

Knowing \(B\) jumps the chance: \(\tfrac{1}{13} \to \tfrac{1}{3}\).

RL IS BUILT FROM CONDITIONAL DISTRIBUTIONS
Transition: \(P(s' \mid s, a)\)
Policy: \(\pi(a \mid s)\)

Each is a whole conditional distribution — a probability for every next state \(s'\) (or action \(a\)), given what we condition on. Every | asks: "what's likely next, given what we know now?"

That's our probability toolkit. Now we use it to formalize every part of the agent–environment loop.

Conditional
08 / 20
PAUSE & THINK

Quick probability check.

Q1 is a worked demo — the recipe is always: ① what is \(\Omega\)? ② model the event ③ compute \(P\). Tap Q2 and Q3 to check yourself.

Q1 · WORKED DEMO · Ω → EVENT → P

Flip 3 fair coins. Find \(P(\text{exactly 2 heads})\).

\(P = 3/8\)

① Sample space. \(\Omega = \{HHH,HHT,HTH,HTT,THH,THT,TTH,TTT\}\); \(|\Omega| = 2^3 = 8\), all equally likely.
② Model the event. \(A = \{HHT, HTH, THH\}\), so \(|A| = 3\).
③ Probability. \(P(A) = \dfrac{|A|}{|\Omega|} = \dfrac{3}{8}.\)

Q2 · YOUR TURN · Ω → EVENT → P

Roll two fair dice. What is \(P(\text{sum} = 7)\)? Work the three steps: what is \(\Omega\), which outcomes form the event, then the probability.

\(P = 6/36 = 1/6\)

① \(\Omega\). Ordered pairs \((d_1,d_2)\), \(d_i\in\{1,\ldots,6\}\); \(|\Omega| = 36\).
② Event. \(A = \{(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)\}\), \(|A| = 6\).
③ Probability. \(P(A) = \dfrac{6}{36} = \dfrac{1}{6}.\)

tap to reveal
Q3 · CONDITIONAL · BUILD IT STEP BY STEP

Two chests, you can't tell them apart: 🎁 a Legendary (rare drop 80%) and 📦 a Standard (50%), each equally likely. You get 2 pulls. Pull #1 — RARE! 🎉 For pull #2: stick or switch?

① Prior — before any pull

You can't tell the chests apart, so each is Legendary or Standard with equal chance: \(P(\text{Leg}) = P(\text{Std}) = \tfrac12.\)

② How likely was a rare at all?

Average the two rare-rates over your prior (law of total probability):
\(P(\text{rare}) = \underbrace{\tfrac12(0.8)}_{\text{Leg branch}} + \underbrace{\tfrac12(0.5)}_{\text{Std branch}} = 0.65.\)

③ Update your belief — this is Bayes

\(P(\text{Leg}\mid\text{rare}) = \dfrac{P(\text{rare}\mid\text{Leg})\,P(\text{Leg})}{P(\text{rare})} = \dfrac{0.8 \cdot 0.5}{0.65} = \tfrac{8}{13} \approx 62\%.\)
So \(P(\text{Std}\mid\text{rare}) = \tfrac{5}{13}\). The rare made Legendary more believable: \(50\% \to 62\%\).

📜 BAYES' THEOREM \(P(H\mid E) = \dfrac{P(E\mid H)\,P(H)}{P(E)}\) — posterior ∝ likelihood × prior. The single most-used equation in RL belief updates. (Bayes, 1763.)
④ STICK — pull the same chest again

Mix the rare-rates by your updated belief:
\(\underbrace{0.8}_{\text{Leg drops rare}}\cdot\underbrace{\tfrac{8}{13}}_{\text{belief it's Leg}} + \underbrace{0.5}_{\text{Std drops rare}}\cdot\underbrace{\tfrac{5}{13}}_{\text{belief it's Std}} = \tfrac{8.9}{13} \approx 68\%.\)
Each term reads: (this chest's rare-rate) × (your belief you're holding it). E.g. \(0.8 \cdot \tfrac{8}{13}\) = "I'm \(\tfrac{8}{13}\) sure it's Legendary, and a Legendary drops rare 80% of the time."

⑤ SWITCH — try the other chest

If this one is Legendary the other is Standard, and vice-versa — so the other chest is Legendary with prob \(\tfrac{5}{13}\):
\(0.8\cdot\tfrac{5}{13} + 0.5\cdot\tfrac{8}{13} = \tfrac{8}{13} \approx 62\%.\)

⑥ Decision Stick — 68% > 62%
📌 BELIEF That updated probability is your belief — using it to pick the better chest is how observations turn into smarter actions.
⚡ DÉJÀ VU? Now imagine 3 chests, 20 pulls — that's the multi-armed bandit from Lecture 1. Belief is exactly the math behind explore-vs-exploit.
tap to start →
Probability Quiz
09 / 20
BRIDGE · PROBABILITY → RL

What's actually different?

The chest problem looked a lot like the 3-box bandit you played in Lecture 1. Where do they actually diverge?

CHEST PROBLEM (today)

Rates are known.

You're given the rates — 🎁 80% rare, 📦 50% rare. You only need to figure out which chest is which.

Bayesian update is exact: one observation directly maps to a posterior.

MULTI-ARMED BANDIT (L1)

Rates are hidden.

You don't know any box's drop rate. You learn the rates only by pulling — every action also produces data.

No closed-form answer. Explore-vs-exploit kicks in. ε-greedy lives here.

⏭ ON TO RL Same idea, harder setting: maintain a belief about each option, use it to choose actions. The probability tools we just built are the language of RL — time to start naming the parts.
Bridge
10 / 20
★ OPTIONAL APPENDIX

Deep dive into the
probability world.

The next nine slides peek under the hood — σ-algebras, measures, almost-sure convergence, the geometry of random variables, Bayesian vs frequentist views, and even a tour of the Bayesian brain. Interestingly abstract (and honestly, hard).

⚠️
A FRIENDLY HEADS-UP

If you don't follow everything — that's totally okay. None of this is a prerequisite for the rest of the course. Skim it, savor it, or skip ahead. You can always come back.

The aim isn't mastery — it's a guided look at how mathematicians think about probability.

★ Deep Dive Begins
11 / 20
★ OPTIONAL · DEEP DIVE · 1 OF 8 · TRIPLE

The formal object: \((\Omega, \mathcal{F}, P)\).

The probability space is a three-piece object. We've used \(\Omega\) and \(P\) all along; the hidden third piece is \(\mathcal{F}\) — the family of allowable events. Together they form the probability triple.

SAMPLE SPACE
\(\Omega\)

Set of all possible outcomes \(\omega\). A single trial picks one.

🎲 \(\Omega = \{1,\ldots,6\}\)
🎯 \(\Omega = [0, 2\pi)\) (dart angle)
σ-ALGEBRA
\(\mathcal{F}\)

A family of subsets of \(\Omega\) — the events you're allowed to ask about. Closed under complement, closed under countable union, and contains \(\Omega\).

🎲 Discrete: \(\mathcal{F} = 2^\Omega\) (all 64 subsets)
🎯 Continuous: Borel σ-algebra on \([0, 2\pi)\)
PROBABILITY MEASURE
\(P : \mathcal{F} \to [0,1]\)

Assigns a number to each event in \(\mathcal{F}\). Rules: \(P(\Omega) = 1\); for disjoint \(A_1, A_2, \ldots \in \mathcal{F}\), \(P\!\left(\bigcup_i A_i\right) = \sum_i P(A_i)\) (countable additivity).

🎲 \(P(\{2,4,6\}) = 1/2\)
🎯 \(P([0, \pi)) = 1/2\)
★ Triple
12 / 20
★ OPTIONAL · DEEP DIVE · 2 OF 8

Probability is just a measure.

Two ideas fit together. Events are sets — so logic on events is just set algebra. Probability is a "size function" on those sets — like length, area, or volume. The whole machinery has a name: measure theory.

EVENTS ↔ SETS · LOGIC IS SET ALGEBRA
"A or B" → \(A \cup B\)
"A and B" → \(A \cap B\)
"not A" → \(A^c\)
"A implies B" → \(A \subseteq B\)
"impossible" → \(\emptyset\)
"certain" → \(\Omega\)

A σ-algebra is closed under \(\cup, \cap, ^c\) — exactly so the events you can talk about stay in the family.

A MEASURE IS A "SIZE FUNCTION"

A measure on \((\Omega, \mathcal{F})\) is any function \(\mu : \mathcal{F} \to [0, \infty]\) with:

① \(\mu(\emptyset) = 0\)
② \(\mu\!\left(\bigcup_i A_i\right) = \sum_i \mu(A_i)\) for disjoint \(A_i\)

A probability measure adds one rule: \(P(\Omega) = 1\).

Total "mass" equals 1 — the only thing that makes probability special.

SAME AXIOMS · MANY WORLDS
📏 🟦 🧊
Lebesgue
length / area / volume
on \(\mathbb{R}, \mathbb{R}^2, \mathbb{R}^3, \ldots\)
🔢
Counting
\(\mu(A) = |A|\)
on a countable set
🎲
Probability
any \(P\) with \(P(\Omega) = 1\)
(normalized)

Studying all of these together is measure theory (Lebesgue, 1902) — one foundation under modern integrals, probability, and signal processing.

★ Measures
13 / 20
★ OPTIONAL · DEEP DIVE · 3 OF 8 · RIGOR

Rigor: a.s. convergence and the Strong Law.

Remember slides 6–7? The coin frequency settled near \(\tfrac12\), the dice average settled near 3.5 — but neither stopped wobbling. How do you state "it converges" precisely, when the path keeps fluctuating? Two answers, two strengths — both made possible by Kolmogorov's measure theory (1933).

WEAK LAW · \(\xrightarrow{P}\)

"At any huge \(n\), you're probably close."

Pick a massive \(n\) (say \(10^6\)). The probability that the running average at that exact step is far from \(\tfrac12\) is nearly zero.

\(P\!\left(|\bar{X}_n - \mu| > \varepsilon\right) \to 0\)

A statement about fixed-time probability. Says nothing about whole paths.

STRONG LAW · \(\xrightarrow{\text{a.s.}}\)

"In every universe but a measure-zero one, you converge."

Run the experiment forever. The sequence of running averages converges to \(\tfrac12\) for every universe, except a collection of pathological universes whose total probability is \(0\).

\(P\!\left(\lim_{n\to\infty}\bar{X}_n = \mu\right) = 1\)

A statement about whole paths. To even ask "what's the measure of the bad set?" you need \(\mathcal{F}\).

WHAT THIS UNLOCKED
📊
Stochastic processes
Markov chains · Brownian motion
Stochastic integrals
Itô calculus · option pricing
📡
Information theory
Shannon entropy · codes
🤖
RL convergence
Q-learning a.s. convergence proofs
★ Rigor
14 / 20
★ OPTIONAL · DEEP DIVE · 4 OF 8 · UNIFICATION

Unification: discrete and continuous, one frame.

Pre-Kolmogorov, dice problems and continuous random variables (gas-particle velocities, daily temperatures, stock prices) needed different machinery — counting on one side, calculus on the other. After 1933, they're the same object: a probability measure on a measurable space. Different sets, identical axioms.

DISCRETE WORLD

🪙 Coin flip · 🎲 Dice · 🎴 Cards · 📦 Bandit arms.

\(\Omega = \{\omega_1, \omega_2, \ldots\}\)
\(\mathbb{E}[X] = \sum_k x_k\, p_X(x_k)\)

Sums. Counting measure underneath.

CONTINUOUS WORLD

🌡 Temperature · 💹 Stock price · 🏃 Reaction time · 📡 Sensor noise.

\(\Omega \subseteq \mathbb{R}\)
\(\mathbb{E}[X] = \int_{\mathbb{R}} x\, f_X(x)\, dx\)

Integrals. Lebesgue measure underneath.

ONE FRAMEWORK · BOTH WORLDS
\(\mathbb{E}[X] = \int_\Omega X(\omega) \, dP(\omega)\)

One Lebesgue integral against the measure \(P\). Whether \(\Omega\) is discrete or continuous, the formula is the same — the measure does the work. LLN, CLT, Bayes all hold simultaneously in both worlds.

★ Unification
15 / 20
★ OPTIONAL · DEEP DIVE · 5 OF 8 · GEOMETRY

Geometry: random variables as vectors.

Sets become spaces; spaces inherit geometry. Once \(L^2\) — the space of square-integrable random variables — is the playground, abstract probability concepts turn into familiar vector geometry.

RANDOM VARIABLES = VECTORS

In \(L^2\), an inner product encodes covariance:

\(\langle X, Y \rangle = \mathbb{E}[XY]\)
\(\|X\|^2 = \mathbb{E}[X^2]\)

Uncorrelatedorthogonal: \(\langle X, Y \rangle = 0\) iff \(\mathrm{Cov}(X,Y) = 0\) (after centering).

† Wait — aren't random variables functions?
Yes: \(X : \Omega \to \mathbb{R}\). And functions are vectors — they live inside an abstract, infinite-dimensional vector space (here, \(L^2\)). You can add them, scale them, take inner products. "Function" and "vector" aren't a contradiction; the second is a coordinate-free way to think about the first. (learn more in functional analysis)

COND. EXPECTATION = PROJECTION

\(\mathbb{E}[X \mid \mathcal{G}]\) is the orthogonal projection of \(X\) onto the subspace of \(\mathcal{G}\)-measurable random variables.

\(\hat{X} = \mathbb{E}[X \mid \mathcal{G}] = \mathrm{proj}_{L^2(\mathcal{G})}\, X\)

The "best guess of \(X\) using only info \(\mathcal{G}\)" is, geometrically, the closest point in that subspace — exactly like dropping a perpendicular.

WHERE THE GEOMETRIC VIEW LIVES
📐
Information geometry
Fisher metric · KL divergence
🚚
Optimal transport
Wasserstein distance
🎨
Diffusion models
Score = \(\nabla \log p\)
🤖
RL value functions
\(V_\pi\) = projection of returns
★ Geometry
16 / 20
★ OPTIONAL · DEEP DIVE · 6 OF 8

A random variable pushes a measure onto \(\mathbb{R}\).

A random variable \(X : \Omega \to \mathbb{R}\) doesn't just turn outcomes into numbers — it carries the probability with it. To ask "what's the chance \(X \in B\)?" we pull \(B\) back to a set of outcomes in \(\Omega\), where probability already lives.

\[ P_X(B) \;\equiv\; (X_* P)(B) \;=\; P\!\left(X^{-1}(B)\right) \;=\; P\!\left(\{\omega : X(\omega) \in B\}\right) \]
\(P_X\) is the pushforward (or induced) measure on \(\mathbb{R}\). It's the probability rule \(X\) creates out of \(P\).
EXAMPLE · TWO COIN FLIPS

\(\Omega = \{HH, HT, TH, TT\}\), each outcome \(\tfrac{1}{4}\). Define \(X(\omega)\) = number of heads.

\(P_X(\{0\}) = P(\{TT\}) = 1/4\)
\(P_X(\{1\}) = P(\{HT, TH\}) = 1/2\)
\(P_X(\{2\}) = P(\{HH\}) = 1/4\)

The distribution we've been calling \(p_X\) is exactly \(P_X\).

WHY IT MATTERS

Two random variables can have the same distribution on totally different sample spaces. Your dice game and a casino's roulette can share \(P_X\), even though their \(\Omega\) and \(P\) look nothing alike.

Expectation can be computed in either space:

\(\displaystyle \mathbb{E}[X] = \int_\Omega X \, dP = \int_{\mathbb{R}} x \, dP_X\)

For \(P_X\) to be a valid measure, \(X\) must be measurable: \(X^{-1}(B) \in \mathcal{F}\) for every Borel \(B\).

★ Pushforward
17 / 20
★ OPTIONAL · DEEP DIVE · 7 OF 8

Two ways to read the same \(P(A)\).

Same axioms (Kolmogorov), same equations — two interpretations of what \(P(A)\) actually means. The split runs through 250 years of statistics and shows up everywhere in modern AI.

Frequentist

\(P(A) = \displaystyle \lim_{n \to \infty} \frac{\#\{A \text{ in } n \text{ trials}\}}{n}\)

Probability is a long-run frequency. Parameters are fixed but unknown; data is random. We use confidence intervals, p-values, and maximum likelihood. Slide 6's coin demo lives in this view.

Trouble: requires a "repeatable experiment." Hard to assign \(P(\text{rain tomorrow})\) — there's only one tomorrow.

Bayesian

\(P(\theta \mid \text{data}) \propto P(\text{data} \mid \theta) \, P(\theta)\)

Probability is a degree of belief. Parameters are uncertain (random); data is observed (fixed). We use priors, posteriors, credible intervals. Slide 9's chest puzzle lives in this view.

Trouble: where does the prior come from? Two analysts with different priors can read the same data and reach different posteriors.

⚖️ IN RL Q-learning takes empirical averages of returns — frequentist in spirit. Thompson sampling, posterior sampling, and "Bayesian RL" maintain a posterior over the world model — Bayesian in spirit. Both ship.
★ Bayes vs Freq
18 / 20
★ OPTIONAL · DEEP DIVE · 8 OF 8

Your brain is a (sometimes broken) Bayesian machine.

The Bayesian brain hypothesis (Helmholtz, 1860s; revived by Knill, Pouget, and Friston in the 2000s) says perception and decisions are posterior inferences: prior expectations meet sensory likelihood, and we act on the result. Same machinery — beautiful when it works, buggy when it doesn't.

\[ \underbrace{P(\text{world} \mid \text{senses})}_{\text{what you perceive}} \;\propto\; \underbrace{P(\text{senses} \mid \text{world})}_{\text{likelihood}} \cdot \underbrace{P(\text{world})}_{\text{prior}} \]

✨ When it wins

  • 👁️ Perception: noisy retinal signals + prior on object shapes → a stable, recognizable scene.
  • 🦾 Motor control: noisy proprioception + prior on body dynamics → reaching that doesn't overshoot.
  • 🗣️ Speech: garbled phonemes + prior on words → "what they probably said."
  • 📚 Learning: evidence updates beliefs about the world model — exactly what RL agents do.

💥 When it breaks

  • 🩺 Base-rate neglect: 1% prevalence + 95% accurate test → most "positives" are false. Doctors and patients miss this.
  • 🪜 Anchoring: the first number you see becomes a strong prior; later estimates drag toward it.
  • 🛡️ Confirmation bias: ambiguous data gets read as confirming the prior. Stubborn beliefs survive contrary evidence.
  • 👥 Stereotypes: we weight the group prior far above the actual base rate. "Shy and methodical" → people guess "engineer" — even when salespeople outnumber engineers ~10:1. The stereotype is real, but the prior we apply is much stronger than the truth.
★ Bayesian Brain
19 / 20
NEXT WEEK · LECTURE 3

From probability tools
to naming the loop.

📌 TODAY · THE LANGUAGE

Outcomes, random variables, expectation, conditional probability, and Bayes — every | in RL is one of these. The bandit teaser shows where they meet RL.

🔭 L3 · NAME EVERY PIECE

State, action, reward, transition, policy — bundled into the MDP. Then we play a doors game and meet two values, V and Q.

Next
20 / 20