Lecture 17

Measures, densities, and
the Radon–Nikodym derivative

Token sets · diffusion noise · singular supports · search agents

Vishnu Boddeti

Connect to the lecture notes

The same measure ideas in four settings

1Discrete mass on a set
Which tokens survive nucleus decoding?
2Density relative to length
How much Gaussian mass lies in an interval?
3A null set for one measure
What happens when two supports separate?
4A density relative to another measure
Can an agent’s new action mass be expressed using its old mass?

Use the notes’ set-based definition: $\nu(A)=\int_A f\,d\mu$. Every calculation below concerns a set and its mass.

Example 1

Nucleus decoding changes the measure over tokens

Example 1 · What is the mathematical object?

A token is a point; a group of tokens is a set

At one fixed prompt

Use a four-token vocabulary $\Omega$. The measurable sets are all subsets of $\Omega$.

The original measure assigns masses $0.45,\ 0.30,\ 0.15,\ 0.10$ to the four singletons.

$P(A)=\sum_{a\in A}P(\{a\})$

Keep a nucleus $N$

Sort tokens by mass. Keep the shortest prefix whose combined mass reaches the cutoff.

Divide each retained mass by $P(N)$; assign zero to removed tokens.

$Q(\{a\})=\dfrac{P(\{a\})}{P(N)}\,\mathbf1_N(a)$

Before moving the control: can removing tokens create mass on a source-null set?

Example 1 · An exact four-token calculation

Keep, remove, and renormalize

Illustrative token masses, not measurements from the paper.
Token$P$Nucleus?$Q$$Q/P$
The0.45
A0.30
This0.15
Other0.10

At cutoff 0.75, the first two tokens carry mass 0.75. Their new masses are 0.60 and 0.40.

Tokens retained
Original retained mass $P(N)$

Try cutoff 1: all tokens return and every ratio is 1.

Whenever tokens are removed, $Q\ll P$, but $P\ll Q$ fails. Which singleton witnesses the failure?

Example 2

Diffusion noise is a measure with a density

Example 2 · A one-coordinate view of the forward corruption

A density value is not a point mass

Fix the clean coordinate at zero

The noisy coordinate has a Gaussian density. The control changes its scale $\sigma$.

$f_\sigma(x)=\dfrac{1}{\sigma\sqrt{2\pi}}e^{-x^2/(2\sigma^2)}$

The demo isolates this kernel; it does not simulate an entire image or a trained denoising model.

Use length as the reference measure

Let $\lambda$ denote Lebesgue measure on the line.

$Q(A)=\int_A f_\sigma(x)\,d\lambda(x)$

For $A=[-0.5,0.5]$, mass is shaded area. A singleton has zero length, so $Q(\{0\})=0$ even when $f_\sigma(0)>1$.

Predict: does a taller, narrower peak put more or less mass inside this fixed interval?

Example 2 · Compute an interval’s mass

Compare height at a point with area over a set

Shading marks $A=[-0.5,0.5]$. The vertical axis rescales to show the full peak; the displayed window is $[-3,3]$.

Density height $f_\sigma(0)$
Interval mass $Q(A)$
Point mass $Q(\{0\})$

Try σ = 0.15. Density height can exceed 1; the integral over the whole line remains 1.

Example 3

WGAN makes a support mismatch visible

Example 3 · The paper’s parallel-line construction

Zero area can still carry all the mass

Two measures in the plane

$P_0$ spreads unit mass evenly along $\{0\}\times[0,1]$.

$P_\theta$ spreads unit mass evenly along $\{\theta\}\times[0,1]$.

Each segment has zero two-dimensional area. These measures therefore have no density relative to planar Lebesgue measure.

Choose the target segment as a set

Let $A_\theta=\{\theta\}\times[0,1]$. If $\theta\ne0$,

$P_0(A_\theta)=0,\qquad P_\theta(A_\theta)=1.$

Thus $P_\theta\not\ll P_0$. No function integrated against $P_0$ can put mass on this source-null set.

If the shift becomes exactly zero, does a derivative relative to $P_0$ become possible?

Example 3 · Inspect the null-set condition

Move the support, not just a curve

Source: x = 0Target: x = θ

The segments’ drawn thickness is for visibility. Their two-dimensional area is zero.

Source mass $P_0(A_\theta)$
Target mass $P_\theta(A_\theta)$

Try θ = 0. The measures coincide, so $dP_\theta/dP_0=1$ almost everywhere—even though neither has an area density.

Example 4

A search agent’s new actions need source support

Example 4 · Apply the Radon–Nikodym theorem from the notes

Express new action mass using old action mass

Keep the agent’s history fixed

Use a small action set: Search A, Search B, Answer now, and Search C.

$P$ is the old action measure; $Q$ is the proposed one. An old logging filter excluded query C, so $P(\{C\})=0$.

The four actions and numeric masses are a teaching example, not a reproduction of Search-R1’s training procedure.

Check existence before dividing

If $Q\ll P$, the theorem gives $w=dQ/dP$ with

$Q(A)=\int_A w\,dP.$

For this finite action set, $w(a)=Q(\{a\})/P(\{a\})$ where $P(\{a\})>0$.

On a source-null set, a finite density cannot create new mass.

Example 4 · Agentic support check

What if a new query was excluded from the old logs?

Same fixed history; mass assignments sum to 1 in each column.
Next actionOld $P$New $Q$$Q/P$
Search A0.50
Search B0.30
Answer now0.20
Search C0

Ratios on shared support reconstruct only the mass assigned to the first three actions. A positive query-C mass prevents a derivative for the whole target measure.

Target mass on old support

For $A=\{\text{Search B},\text{Answer now}\}$, verify $Q(A)=\sum_{a\in A}P(\{a\})w(a)$.

Return to the lecture’s central question

A density always needs a reference measure

1Discrete mass: sum singleton masses over a set.
2Ordinary density: integrate a function against Lebesgue measure.
3Absolute continuity: every source-null set must remain target-null.
4Radon–Nikodym derivative: a density relative to the chosen source measure.

Before writing $dQ/dP$, name $P$, name $Q$, and test the null-set condition.

Practice problems

Each scenario hides a mathematical structure from this lecture. Identify the structure, justify it, and work through the resulting problem.

Problem 1 Data augmentation

Define the randomness in an augmentation pipeline

Every time an image is used for training, the pipeline chooses one of three crops and may flip it. A reproducibility audit asks a deceptively simple question: what, exactly, is the random experiment?

Model evidence

Use the six crop-flip pairs in $\{1,2,3\}\times\{0,1\}$ as equally weighted elementary outcomes: assign mass $1/6$ to each pair. The second entry records whether the image is flipped.

  1. What is the outcome space, and what probability belongs to each elementary outcome?
  2. Which outcomes make up “crop 1 or a flipped image,” and what is that event's probability?
  3. Do the assigned probabilities satisfy the probability axioms?
Problem 2 Robust regression

Normalize a heavy-tailed error model

A few large residuals keep appearing, so a Gaussian model feels too unforgiving. You try a density proportional to $e^{-|r|}$ instead—but “proportional to” is not yet a probability model.

Model evidence

$p(r)=ce^{-|r|}$ for $r\in\mathbb{R}$.

  1. What normalization constant turns the expression into a density?
  2. What mass does the density assign to the event $A_a=\{r\in\mathbb R:|r|>a\}$, where $a>0$?
  3. Which familiar robust loss appears as the negative log-density?
Problem 3 Agent action measures

Can a search agent change its action measure?

Keep one search-agent prompt and tool history fixed. Four possible next actions represent three search queries and finishing. Compare a logging measure P with a proposed measure Q on this same finite action set.

Model evidence

$\Omega=\{A,B,C,F\}$, where $A,B,C$ are search queries and $F$ means finish. Assign $P=(0.5,0.2,0.2,0.1)$ and $Q=(0.3,0.3,0.3,0.1)$ in that order.

  1. Check that both mass assignments define probability measures. Does $Q\ll P$ hold? Find $w=dQ/dP$ at each action.
  2. For the event $E=\{B,C\}$, calculate $Q(E)$ directly and check that $\sum_{a\in E}w(a)P(\{a\})$ gives the same mass.
  3. Now a logging filter removes query $C$ and reallocates its mass to $A$, giving $P_0=(0.7,0.2,0,0.1)$. Does $dQ/dP_0$ exist? Identify a set that proves your answer.
Problem 4 Geometric probability

A random chord

Take a unit circle and draw a chord uniformly at random. What is the probability that this “random chord” is longer than $\sqrt{3}$?