Dependence, the posterior, and the cost that picks the estimate
\[ % Number sets \newcommand{\Nat}{\mathbb{N}} \newcommand{\Integer}{\mathbb{Z}} \newcommand{\Real}{\mathbb{R}} \newcommand{\Complex}{\mathbb{C}} % Operators \newcommand{\SNR}{\operatorname{SNR}} \newcommand{\tr}{\operatorname{tr}} \newcommand{\re}{\operatorname{Re}} \newcommand{\im}{\operatorname{Im}} \newcommand{\sign}{\operatorname{sign}} \newcommand{\rect}{\operatorname{rect}} \newcommand{\sinc}{\operatorname{si}} \newcommand{\erf}{\operatorname{erf}} \newcommand{\erfc}{\operatorname{erfc}} \newcommand{\kurt}{\operatorname{kurt}} \newcommand{\diag}{\operatorname{diag}} \newcommand{\MSE}{\operatorname{MSE}} \newcommand{\argmin}{\operatorname*{argmin}} \newcommand{\argmax}{\operatorname*{argmax}} \newcommand{\bias}{\operatorname{bias}} \newcommand{\Bin}{\operatorname{Bin}} % Delimiters \newcommand{\paren}[1]{\left(#1\right)} \newcommand{\bracket}[1]{\left[#1\right]} \newcommand{\set}[1]{\left\{#1\right\}} \newcommand{\abs}[1]{\left\lvert #1 \right\rvert} \newcommand{\norm}[1]{\left\lVert #1 \right\rVert} \newcommand{\ip}[1]{\left\langle #1 \right\rangle} % Notation \newcommand{\dd}{\,\mathrm{d}} \newcommand{\tran}{^{\top}} \newcommand{\conv}{\ast} \newcommand{\conj}{^{*}} \newcommand{\herm}{^{\mathsf{H}}} \newcommand{\opt}{^{\star}} % Expectation and variance % \newcommand{\E}[1]{\mathbb{E}\!\left[#1\right]} \newcommand{\E}[2][]{\mathbb{E}_{#1}\!\left[#2\right]} \newcommand{\Var}[1]{\mathbb{V}\!\left[#1\right]} % Distributions \newcommand{\Gauss}{\mathcal{N}} \newcommand{\Uniform}{\mathcal{U}} \newcommand{\FT}{\mathcal{F}} % Probability \newcommand{\Prob}[1]{\mathbb{P}\!\left(#1\right)} % Misc \newcommand{\bsy}[1]{\boldsymbol{#1}} \newcommand{\calR}{\mathcal{R}} \newcommand{\calC}{\mathcal{C}} \]

In each case you are told one reading and asked about the other. What is the observation worth?
Guess before the pictures: parity for pips, height for income, elevation for land.
Dependence. What one variable says about another lives in their joint law, and conditioning is how you read it off.
Inference with a prior. Model the unknown as random, and the observation turns the prior into a posterior. A cost then says which single number, or which decision, to report.
In the notes Joint Distributions and Marginals · Conditional Distributions · Functions of Two Random Variables · The Posterior · Cost, Risk, and Pointwise Minimization · Bayes Decision and Classification · Bayesian Estimation: MMSE and MAP · Two Scalar Problems: Fusion and Denoising

Joint CDF and density \[F_{XY}(x,y)=\Prob{X\le x,\ Y\le y},\qquad f_{XY}(x,y)=\frac{\partial^2F_{XY}(x,y)}{\partial x\,\partial y}.\]

The die and the terrain put mass only where the two readings agree; the population has no such structure. Discrete, continuous, or one of each: the object is the same, a nonnegative assignment of total mass one to the plane.
\[f_X(x)=\int f_{XY}(x,y)\dd y,\qquad f_Y(y)=\int f_{XY}(x,y)\dd x .\]

A fair die and a fair coin, and no trace of the fact that the mass sat only where pips and parity agree. All of the dependence was in the joint.

Observing \(X\) says nothing about \(Y\) in the first, pins \(Y\) to a band in the second, and in the third says “near \(+x\) or near \(-x\)” without choosing. Only the joint density tells them apart.
Independence \[f_{XY}(x,y)=f_X(x)\,f_Y(y).\]
Sums split always: \(\E{aX+bY}=a\E{X}+b\E{Y}\) needs only a joint law to exist.
Products split only under independence: \(\E{g(X)h(Y)}=\E{g(X)}\E{h(Y)}\).
The asymmetry is worth remembering. A sum of dependent terms is still easy to average; a product of them is not.
Conditional density \[f_{Y\mid X}(y\mid x)=\frac{f_{XY}(x,y)}{f_X(x)}:\] take the slice of the joint at the observed \(x\) and renormalize it.
Independence is exactly \(f_{Y\mid X}(y\mid x)=f_Y(y)\): the slice looks like the whole.
An observation is worth something exactly when the conditional differs from the marginal. The three pairs show the three possibilities.

Odd rules out three faces and doubles the weight of the other three. A guess of the face gets better, but not certain.

Short slice, tall slice, everyone: one curve. The height is measured, and the estimate of the income does not move. That is independence, seen from the conditioning side.

The elevation settles the land question outright: the probability is \(0\) below sea level and \(1\) above. The other way round, one bit only cuts the elevation density at sea level. Dependence is symmetric; what each direction is worth is not.
The joint can be sliced either way, \(f_{XY}=f_{Y\mid X}\,f_X=f_{X\mid Y}\,f_Y\), so
Bayes’ rule \[f_{Y\mid X}(y\mid x)=\frac{f_{X\mid Y}(x\mid y)\,f_Y(y)}{f_X(x)},\qquad f_X(x)=\int f_{X\mid Y}(x\mid y)\,f_Y(y)\dd y .\]
Turning the conditional around is the whole of Bayesian inference. The second part of the week is this formula, used with intent.
A function of two variables moves probability mass around the plane; the density picks up the Jacobian of the map, the ratio by which it stretches area.

The notes have the change-of-variables formula. Three results from it matter for signals, and the next three slides show them.

Shear, then marginalize: that is where the convolution of densities for an independent sum comes from, the smoothing step of the first week drawn as a map.

The magnitude of complex Gaussian noise, which is what an envelope detector sees, is Rayleigh distributed. Read backwards (Box–Muller), two uniforms make two Gaussians.

The envelope construction read backwards. This is how Gaussian noise is generated in software from a uniform random-number generator.

Dependence can make a sum smaller than either term: variances add only for independent terms. And the Cauchy law of the first week is just the ratio of two ordinary Gaussians.
Give the unknown \(Y\) a prior \(f_Y(y)\), and let the observation depend on it through \(f_{X\mid Y}(x\mid y)\). Now a joint law exists, and conditioning is inference:
Posterior \[f_{Y\mid X}(y\mid x)=\frac{f_{X\mid Y}(x\mid y)\,f_Y(y)}{f_X(x)} \qquad\propto\qquad \text{likelihood}\times\text{prior}.\]
Last week’s semicolon, \(f(x;\phi)\), has become a bar, \(f_{X\mid Y}(x\mid y)\). The formula for the likelihood is the same; what changed is that \(Y\) now has a law of its own.

Against last week’s picture, one thing changed: the node on the left acquired a law.
The posterior sits between prior and data, narrower than either: each source of information sharpens the other. The data’s pull grows with every observation; the prior’s does not.
How much of the Earth is land? Drop random points on a globe and record land or water. With a flat prior on the land fraction \(\phi\) and \(s\) land points out of \(N\), \[f_{\Phi\mid\mathbf X}(\phi\mid\mathbf x)\propto\phi^{s}(1-\phi)^{N-s},\qquad 0\le\phi\le1 .\]

With one observation the prior still dominates; by \(N=32\) it hardly matters. The prior never has to be switched off: the data retire it on their own.
Conditional mean \[\E{Y\mid x}=\int y\,f_{Y\mid X}(y\mid x)\dd y\]
At the observed \(x\) this is an ordinary mean of an ordinary density. Read as a function of the random \(X\), \(\E{Y\mid X}\) is itself a random variable, with the tower property \(\E{\E{Y\mid X}}=\E{Y}\).
With no data the best constant guess was the prior mean \(\E{Y}\). Observation replaces it by the conditional mean: start at the prior mean and let the data supply a correction.
A usable answer is one number, or one decision. Which one follows from what a mistake costs, \(\calC(y,\widehat y)\ge0\).
Conditional risk and Bayes risk \[R(\widehat y\mid x)=\int\calC(y,\widehat y)\,f_{Y\mid X}(y\mid x)\dd y,\qquad R(\widehat y(\cdot))=\iint\calC(y,\widehat y(x))\,f_{XY}(x,y)\dd y\dd x .\]
The first belongs to this data set and a candidate answer; the second to the rule, before any data are seen. It is the number by which two procedures are compared.
Pointwise minimization The rule with the smallest Bayes risk minimizes the conditional risk separately at each observed \(x\).

An optimization over all possible rules collapses into one scalar problem per observation. And a mean need not be a plausible value.
Two hypotheses with prior probabilities \(P_0,P_1\), and cost \(C_{ij}\) for deciding \(i\) when \(j\) is true. Minimizing pointwise:
Bayes decision rule Decide \(H_1\) where \[\Lambda(\mathbf x)=\frac{f_{X\mid H}(\mathbf x\mid H_1)}{f_{X\mid H}(\mathbf x\mid H_0)} \;>\;\frac{P_0\,(C_{10}-C_{00})}{P_1\,(C_{01}-C_{11})}.\]
The same statistic as Neyman–Pearson. A false-alarm budget and an average cost choose the same test and differ only in the threshold.

The data decide the curve; what you believe and what you stand to lose decide where on it you sit. A smoke alarm and a spam filter sit at opposite ends.
The likelihood ratio updates the prior odds \[\frac{\Prob{H_1\mid\mathbf x}}{\Prob{H_0\mid\mathbf x}}=\Lambda(\mathbf x)\,\frac{P_1}{P_0}.\]
\(\Lambda\) is exactly the factor by which the data move your belief. Everything else in the threshold is what you believed and what you stand to lose.
With a discrete label \(Y\in\set{1,\dots,M}\) the same pointwise rule answers, at each \(\mathbf x\), with the label of smallest expected cost; with equal costs, the largest posterior:
Bayes classifier \[\widehat y(\mathbf x)=\argmax_j\ P_j\,f_{X\mid Y}(\mathbf x\mid j).\]
The best any classifier can do when the laws are known. Every learned classifier is an attempt to approximate it from data.
At each \(x\) the largest weighted density wins. The boundaries sit where two curves cross, shifted toward the class that is less likely a priori.
For \(\calC=(y-\widehat y)^2\) the conditional risk is a quadratic in \(\widehat y\): \[\frac{\dd}{\dd\widehat y}\int(y-\widehat y)^2f_{Y\mid X}(y\mid x)\dd y =-2\paren{\E{Y\mid x}-\widehat y}=0 \quad\Longrightarrow\quad\widehat y_{\text{MMSE}}=\E{Y\mid x}.\]
The best estimate there is Over all data, \(\E{Y\mid X}\) minimizes \(\E{(Y-g(X))^2}\) over every function \(g\), linear or not. Much of this course computes it, or an approximation to it.
The error of \(\E{Y\mid X}\) is what the posterior still does not know, averaged over the data:
Law of total variance \[\E{(Y-\E{Y\mid X})^2}=\E{\Var{Y\mid X}},\qquad \Var{Y}=\underbrace{\E{\Var{Y\mid X}}}_{\text{left unexplained}}+\underbrace{\Var{\E{Y\mid X}}}_{\text{explained by }X} .\]
The prior spread splits into the part the observation explains and the part it cannot. For the three pairs: the population explains nothing, the terrain everything, the die something in between.
Orthogonality of the MMSE error \[\E{\paren{Y-\E{Y\mid X}}\,g(X)}=0\qquad\text{for all } g .\]
Otherwise adding a multiple of \(g(X)\) would lower the error. By the tower property the expectation is \(\E{\paren{\E{Y\mid X}-\E{Y\mid X}}g(X)}=0\).
Optimal means: nothing left in the data that could still explain the error. This is the characterization, not a side property.
For a cost that is \(0\) inside a tiny window around the truth and \(1\) outside, the best answer is the value the posterior makes most probable:
MAP estimate \[\widehat y_{\text{MAP}}=\argmax_y\ f_{X\mid Y}(x\mid y)\,f_Y(y).\]
MAP is maximum likelihood plus a prior. Caveat: a mode moves under a change of variables; the mean does not.
For a symmetric, single-peaked posterior they coincide. Away from symmetry they answer different questions: the most probable value against the value with least squared error.
\[\widehat y_{\text{Bayes}}(x)=\argmin_{\widehat y}\int\calC(y,\widehat y)\,f_{Y\mid X}(y\mid x)\dd y\]
| unknown | cost | answer |
|---|---|---|
| two hypotheses | hit or miss, with costs | likelihood-ratio test |
| \(M\) classes | costs \(C_{ij}\) | Bayes classifier |
| a continuum | squared error | posterior mean |
| a continuum | hit or miss | posterior mode |
Detection and estimation are one problem, differing only in the cost and in whether the unknown is discrete or continuous.
\(X_k=Y+N_k\), the noises independent of each other and of \(Y\). The log-posterior is a sum: \[\log f_{Y\mid\mathbf X}(y\mid\mathbf x)=\underbrace{\log f_Y(y)}_{\text{prior}} +\underbrace{\sum_{k}\log f_{N_k}(x_k-y)}_{\text{one term per measurement}}+\text{const}.\]
Everything below is this line under different choices of prior and noise. Fusion adds likelihood terms; denoising adds an informative prior as one more term.

Two thermometers with independent Gaussian errors \(\sigma_1^2,\sigma_2^2\) and no prior preference. Completing the square:
Precision-weighted fusion \[\frac{1}{\sigma_{\text{post}}^2}=\frac{1}{\sigma_1^2}+\frac{1}{\sigma_2^2},\qquad \widehat y=\sigma_{\text{post}}^2\paren{\frac{x_1}{\sigma_1^2}+\frac{x_2}{\sigma_2^2}} .\]
Precisions add, and the estimate is the precision-weighted average: pulled toward the sharper reading, never worse than either. A useless sensor drops out by itself.
Shrinkage toward the prior Prior \(\Gauss(m_0,\sigma_0^2)\), \(N\) measurements with noise \(\sigma^2\): \[\widehat y=\lambda\,\overline x+(1-\lambda)\,m_0,\qquad \lambda=\frac{N\sigma_0^2}{\sigma^2+N\sigma_0^2}.\]
Few or noisy data: \(\lambda\approx0\), trust the prior. Many or clean data: \(\lambda\to1\), trust the sample mean. The prior acts as \(\sigma^2/\sigma_0^2\) extra measurements, all reading \(m_0\).
The posterior is Gaussian, so its mean and mode agree: this one formula is the MMSE and the MAP estimate at once.
A vague prior (\(\sigma_0^2\gg\sigma^2\)) is overruled by the first measurement; a confident one needs many. Either way the weight goes to one: with enough data every reasonable prior agrees.
The shrinkage factor Observe \(X=Y+N\) once, prior \(\Gauss(0,\sigma_Y^2)\): \[\widehat y_{\text{MMSE}}=\widehat y_{\text{MAP}}=\frac{\sigma_Y^2}{\sigma_Y^2+\sigma_N^2}\,x .\]
The estimate shrinks the observation by exactly the fraction of the observed power that is signal.
A signal that is mostly zero has a Laplacian prior, \(f_Y(y)\propto e^{-\abs{y}/b}\). MAP minimizes \((x-y)^2/2\sigma^2+\abs{y}/b\):
Soft thresholding \[\widehat y_{\text{MAP}}=\sign(x)\,\max\paren{\abs{x}-\sigma^2/b,\ 0}.\]
MAP sets every small observation exactly to zero; the mean only shrinks smoothly. A Gaussian prior is a quadratic penalty and gives a linear estimator; the Laplacian’s \(\abs{y}\) penalty is the origin of every sparse-recovery method.
| estimator | assumes | needs |
|---|---|---|
| MMSE, MAP | the full joint law | the posterior |
| ML | the likelihood only | \(f_{X\mid Y}\) |
| restricted to a form (e.g. linear) | less | fewer quantities |
| fitted to data | nothing about the law | a training set |
Read top to bottom: more assumptions buy better performance when they hold; fewer are hungrier for data but survive being wrong. The Gaussian is the one model where the cheap restricted forms lose nothing.
Tweedie’s formula For Gaussian noise \(X=Y+N\), \(N\sim\Gauss(0,\sigma^2)\), and any prior: \[\E{Y\mid X=x}=x+\sigma^2\,\frac{\dd}{\dd x}\log f_X(x).\]
It needs only the density of the observations, which can be learned from data, and not the prior.
It is the identity modern diffusion and score-based image denoisers are built on: the posterior mean of this week, computed by a network that has learned \(\log f_X\).
This week