Mathematical Foundations of AI & ML
Unit 12: Uncertainty in Predictions
FAU Erlangen-Nürnberg
By the end of this lecture, students can:
Same predictions, different error bars: an overconfident NN ensemble (left, bars too small — points miss the diagonal), an underconfident GP (middle, bars too large), and a well-calibrated model (right). The point estimates look similar; only the honesty of the error bar differs. Source: (Tran et al. 2020) Fig. 4 (parity plots, formation-energy \(\Delta E\)).

\[ p(\mathbf{y}^* | \mathbf{x}^*, \mathcal{D}) = \int p(\mathbf{y}^* | \mathbf{x}^*, \theta) \, p(\theta | \mathcal{D}) \, d\theta \]

\[ \text{Var}[\mathbf{y}^*] = \underbrace{\mathbb{E}_\theta[\sigma^2(\theta)]}_{\text{aleatory}} + \underbrace{\text{Var}_\theta[\boldsymbol{\mu}(\theta)]}_{\text{epistemic}} \]
| Approach | Output | Uncertainty | Cost |
|---|---|---|---|
| MLE/MAP | Single \(\hat{\mathbf{y}}\) | None (or ad-hoc) | Low |
| Bayesian (exact) | Full \(p(\mathbf{y}^*|\mathbf{x}^*,\mathcal{D})\) | Principled | High |
| Bayesian (approx.) | Approximate distribution | Approximate | Moderate |
\[ p(\mathcal{D} | \mathcal{M}) = \int p(\mathcal{D} | \theta, \mathcal{M}) \, p(\theta | \mathcal{M}) \, d\theta \]


\[ \gamma = \sum_i \frac{\lambda_i}{\lambda_i + \alpha} \]

\[ f(\mathbf{x}) = \mathbf{w}^\top \boldsymbol{\phi}(\mathbf{x}), \quad \mathbf{w} \sim \mathcal{N}(\mathbf{u}, \mathbf{S}) \;\Rightarrow\; f \sim \mathcal{GP}(m, k) \]
\[ m(\mathbf{x}) = \mathbf{u}^\top \boldsymbol{\phi}(\mathbf{x}), \qquad k(\mathbf{x}, \mathbf{x}') = \boldsymbol{\phi}(\mathbf{x})^\top \mathbf{S} \, \boldsymbol{\phi}(\mathbf{x}') \]

\[ k(x, x') = \frac{\sigma^2}{J} \sum_{i=1}^{J} \phi_i(x)\,\phi_i(x') \]
\[ k(x,x') = \int_{-\infty}^{\infty} \phi_c(x)\,\phi_c(x')\, dc \;\propto\; \exp\!\left(-\frac{(x-x')^2}{2(\sqrt{2}\ell)^2}\right) \]
\[ k(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \exp\!\left(-\frac{\|\mathbf{x} - \mathbf{x}'\|^2}{2\ell^2}\right) \]
\[ \boldsymbol{\mu}^*(\mathbf{x}^*) = \mathbf{k}_*^\top (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} \mathbf{y} \]
\[ \sigma^{*2}(\mathbf{x}^*) = k(\mathbf{x}^*, \mathbf{x}^*) - \mathbf{k}_*^\top (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} \mathbf{k}_* \]
\[ \log p(\mathbf{y} | \mathbf{X}) = -\frac{1}{2}\mathbf{y}^\top(\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1}\mathbf{y} - \frac{1}{2}\log|\mathbf{K} + \sigma_n^2 \mathbf{I}| - \frac{N}{2}\log 2\pi \]


Short \(\ell = 0.1\)
Prior
Short \(\ell = 0.1\)
Posterior
Long \(\ell = 5\)
Prior
Long \(\ell = 5\)
Posterior
Strengths
Limitations
\[ p(\mathbf{y}|\mathbf{x}) = \sum_{k=1}^{K} \pi_k(\mathbf{x}) \, \mathcal{N}(\mathbf{y} | \boldsymbol{\mu}_k(\mathbf{x}), \sigma_k^2(\mathbf{x})) \]

MC Dropout predictive uncertainty on the Mauna Loa CO\(_2\) dataset. Red = predictive mean; shaded = uncertainty band. Standard dropout (a) underestimates; MC Dropout with ReLU (c) grows uncertainty outside training range. (Gal and Ghahramani 2016, fig. 2)
Results on a toy regression task: x-axis denotes x. On the y-axis, the blue line is the ground truth curve, the red dots are observed noisy training data points and the gray lines correspond to the predicted mean along with three standard deviations. Left most plot corresponds to empirical variance of 5 networks trained using MSE, second plot shows the effect of training using NLL using a single net, third plot shows the additional effect of adversarial training, and final plot shows the effect of using an ensemble of 5 networks respectively. (Lakshminarayanan et al. 2017, fig. 1)


| Method | Type | Cost | Calibration | Scalability |
|---|---|---|---|---|
| GP | Exact Bayesian | \(O(N^3)\) | Excellent | Small \(N\) |
| MC Dropout | Approx. Bayesian | \(T \times\) inference | Good | Any |
| Deep ensemble | Frequentist | \(M \times\) training | Very good | Any |
| MDN | Direct | 1× training | Requires tuning | Any |



\[ \mathrm{EI}(\mathbf{x}) = \left(\mu(\mathbf{x}) - f^+ - \epsilon\right)\Phi(Z) + \sigma(\mathbf{x})\,\phi(Z), \quad Z = \frac{\mu(\mathbf{x}) - f^+ - \epsilon}{\sigma(\mathbf{x})} \]

© Philipp Pelz - Mathematical Foundations of AI & ML