Closed-form derivations of posterior mean distribution, entropic risk deviation, and AVaR deviation for Gaussian push-forwards in Bayesian linear regression.
We work with the linear Gaussian model from Bayesian OED: The Double-Loop Estimator. The prior is \(\boldsymbol{\theta} \sim \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma})\), the likelihood is \(\mathbf{y} \mid \boldsymbol{\theta}, \mathbf{w} \sim
\mathcal{N}(\boldsymbol{\Phi}\boldsymbol{\theta}, \boldsymbol{\Gamma})\) (with \(\boldsymbol{\Phi} \in \mathbb{R}^{K \times D}\) the Vandermonde matrix), and the QoI is \(Q = \boldsymbol{\psi}^\top \boldsymbol{\theta}\) for a row vector \(\boldsymbol{\psi} \in \mathbb{R}^{1 \times D}\).
Posterior Distribution
The posterior is \(\boldsymbol{\theta} \mid \mathbf{y}, \mathbf{w} \sim
\mathcal{N}(\boldsymbol{\mu}_\star, \boldsymbol{\Sigma}_\star)\) where:
The posterior covariance \(\boldsymbol{\Sigma}_\star\) is independent of the observation\(\mathbf{y}\). The posterior mean \(\boldsymbol{\mu}_\star\) is not.
Distribution of the Posterior Mean
Writing \(\boldsymbol{\mu}_\star\) explicitly in terms of \(\mathbf{y} = \boldsymbol{\Phi}\boldsymbol{\theta} + \boldsymbol{\epsilon}\):
The variance \(\sigma_Q^2 := \boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top\) is constant (no dependence on \(\mathbf{y}\)). The mean \(\boldsymbol{\psi}\boldsymbol{\mu}_\star\) is Gaussian with mean \(\boldsymbol{\psi}\boldsymbol{\nu}\) and variance \(\boldsymbol{\psi}\mathbf{C}\boldsymbol{\psi}^\top\).
Entropic Risk Deviation
The entropic risk of \(Q \mid \mathbf{y}\) with risk-aversion \(\lambda > 0\) is:
Because the entropic risk deviation is a deterministic function of the posterior covariance, optimizing over \(\mathbf{w}\) reduces to finding weights that minimize \(\boldsymbol{\psi}\boldsymbol{\Sigma}_\star(\mathbf{w})\boldsymbol{\psi}^\top\). No Monte Carlo approximation is needed for this specific risk measure.
AVaR Deviation
The Average Value at Risk (AVaR) at level \(p \in (0,1)\) of a \(\mathcal{N}(\mu, \sigma^2)\) random variable is:
The posterior mean \(\boldsymbol{\mu}_\star\) is a Gaussian random variable; its distribution is fully determined by \(\mathbf{R}\), the prior, and the noise.
For linear Gaussian models, entropic risk, AVaR, and standard deviation deviations of the push-forward are all deterministic — they depend on \(\mathbf{y}\) only through \(\boldsymbol{\Sigma}_\star\), which is observation-independent.
This means the expected deviation equals the deviation itself, simplifying the optimization problem.
Numerical verification against these closed forms is the basis of the usage tutorial.
Exercises
Show that \(\mathbb{E}[\boldsymbol{\mu}_\star] = \boldsymbol{\mu}\) (the mean of the posterior mean equals the prior mean).
Verify that \(\mathbb{V}[\boldsymbol{\psi}\boldsymbol{\mu}_\star] =
\boldsymbol{\psi}\mathbf{C}\boldsymbol{\psi}^\top\) reduces to \(\boldsymbol{\psi}\boldsymbol{\Sigma}\boldsymbol{\psi}^\top\) as \(\boldsymbol{\Gamma} \to 0\) (noiseless observations).
For \(p \to 1^-\), what happens to the AVaR deviation? Interpret this result.
---title: "Risk-Aware Utility: Gaussian Posterior Expressions"subtitle: "PyApprox Tutorial Library"description: "Closed-form derivations of posterior mean distribution, entropic risk deviation, and AVaR deviation for Gaussian push-forwards in Bayesian linear regression."tutorial_type: analysistopic: experimental_designdifficulty: advancedestimated_time: 25render_time: 7extended_time_reason: "The chain of distributions (prior → posterior mean → push-forward → risk measure) cannot be split without losing the derivation thread."prerequisites: - boed_pred_concepttags: - experimental-design - gaussian - risk-measures - avar - entropic-riskformat: html: code-fold: false code-tools: true toc: trueexecute: echo: true warning: falsejupyter: python3---::: {.callout-tip collapse="true"}## Download Notebook[Download as Jupyter Notebook](notebooks/boed_pred_gaussian_analysis.ipynb):::## Learning ObjectivesAfter completing this tutorial, you will be able to:- Derive the joint distribution of the posterior mean as a Gaussian random variable- Show that the entropic risk deviation of the push-forward QoI is deterministic- Derive the AVaR deviation and its expected value for Gaussian posteriors- Explain why all risk deviation expressions are independent of the specific observation realization (for linear Gaussian models)## PrerequisitesComplete [Goal-Oriented Bayesian OED](boed_pred_concept.qmd) before this tutorial.## Model and NotationWe work with the linear Gaussian model from [Bayesian OED: The Double-Loop Estimator](boed_kl_estimator.qmd).The prior is $\boldsymbol{\theta} \sim \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma})$,the likelihood is $\mathbf{y} \mid \boldsymbol{\theta}, \mathbf{w} \sim\mathcal{N}(\boldsymbol{\Phi}\boldsymbol{\theta}, \boldsymbol{\Gamma})$(with $\boldsymbol{\Phi} \in \mathbb{R}^{K \times D}$ the Vandermonde matrix), andthe QoI is $Q = \boldsymbol{\psi}^\top \boldsymbol{\theta}$ for a row vector$\boldsymbol{\psi} \in \mathbb{R}^{1 \times D}$.### Posterior DistributionThe posterior is $\boldsymbol{\theta} \mid \mathbf{y}, \mathbf{w} \sim\mathcal{N}(\boldsymbol{\mu}_\star, \boldsymbol{\Sigma}_\star)$ where:$$\boldsymbol{\Sigma}_\star= \left(\boldsymbol{\Sigma}^{-1} + \boldsymbol{\Phi}^\top \boldsymbol{\Gamma}^{-1} \boldsymbol{\Phi}\right)^{-1},\quad\boldsymbol{\mu}_\star= \boldsymbol{\Sigma}_\star\!\left(\boldsymbol{\Phi}^\top \boldsymbol{\Gamma}^{-1} \mathbf{y} + \boldsymbol{\Sigma}^{-1} \boldsymbol{\mu}\right).$$The posterior covariance $\boldsymbol{\Sigma}_\star$ is **independent of theobservation** $\mathbf{y}$. The posterior mean $\boldsymbol{\mu}_\star$ is not.## Distribution of the Posterior MeanWriting $\boldsymbol{\mu}_\star$ explicitly in terms of$\mathbf{y} = \boldsymbol{\Phi}\boldsymbol{\theta} + \boldsymbol{\epsilon}$:$$\boldsymbol{\mu}_\star \mid \boldsymbol{\theta}, \boldsymbol{\epsilon}= \mathbf{R}\boldsymbol{\Phi}\boldsymbol{\theta} + \mathbf{R}\boldsymbol{\epsilon} + \boldsymbol{\Sigma}_\star \boldsymbol{\Sigma}^{-1} \boldsymbol{\mu},\quad\mathbf{R} = \boldsymbol{\Sigma}_\star \boldsymbol{\Phi}^\top \boldsymbol{\Gamma}^{-1}.$$Since $\boldsymbol{\theta}$ and $\boldsymbol{\epsilon}$ are independent Gaussians,$\boldsymbol{\mu}_\star$ is a Gaussian random variable:$$\boldsymbol{\mu}_\star \sim \mathcal{N}(\boldsymbol{\nu}, \mathbf{C}),$$where:$$\boldsymbol{\nu}= \mathbf{R}\boldsymbol{\Phi}\boldsymbol{\mu} + \boldsymbol{\Sigma}_\star \boldsymbol{\Sigma}^{-1}\boldsymbol{\mu},\quad\mathbf{C}= \mathbf{R}\boldsymbol{\Phi}\boldsymbol{\Sigma}(\mathbf{R}\boldsymbol{\Phi})^\top + \mathbf{R}\boldsymbol{\Gamma}\mathbf{R}^\top.$$## Push-Forward Through the QoI MapThe posterior push-forward of $Q = \boldsymbol{\psi}^\top \boldsymbol{\theta}$conditioned on $\mathbf{y}$ is:$$Q \mid \mathbf{y}\sim \mathcal{N}\!\left( \boldsymbol{\psi}\boldsymbol{\mu}_\star,\; \boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top\right).$$The variance $\sigma_Q^2 := \boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top$is constant (no dependence on $\mathbf{y}$). The mean $\boldsymbol{\psi}\boldsymbol{\mu}_\star$is Gaussian with mean $\boldsymbol{\psi}\boldsymbol{\nu}$ and variance$\boldsymbol{\psi}\mathbf{C}\boldsymbol{\psi}^\top$.## Entropic Risk DeviationThe entropic risk of $Q \mid \mathbf{y}$ with risk-aversion $\lambda > 0$ is:$$\mathcal{R}_\lambda(Q \mid \mathbf{y})= \boldsymbol{\psi}\boldsymbol{\mu}_\star + \frac{\lambda}{2}\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top.$$The **deviation** $\mathcal{D} = \mathcal{R} - \mathbb{E}[Q \mid \mathbf{y}]$subtracts the posterior mean:$$\mathcal{D}_\lambda(Q \mid \mathbf{y})= \frac{\lambda}{2}\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top= \frac{\lambda}{2}\sigma_Q^2.$$This is **deterministic** — independent of $\mathbf{y}$ and hence of the specificobservation realization. Therefore:$$\mathbb{E}\!\left[\mathcal{D}_\lambda(Q \mid \mathbf{y})\right]= \frac{\lambda}{2}\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top.$$::: {.callout-note}## Implication for optimizationBecause the entropic risk deviation is a deterministic function of the posteriorcovariance, optimizing over $\mathbf{w}$ reduces to finding weights that minimize$\boldsymbol{\psi}\boldsymbol{\Sigma}_\star(\mathbf{w})\boldsymbol{\psi}^\top$.No Monte Carlo approximation is needed for this specific risk measure.:::## AVaR DeviationThe Average Value at Risk (AVaR) at level $p \in (0,1)$ of a$\mathcal{N}(\mu, \sigma^2)$ random variable is:$$\mathrm{AVaR}_p(X)= \mu + \sigma \cdot \frac{\phi(\Phi^{-1}(p))}{1 - p},$$where $\phi$ and $\Phi^{-1}$ are the standard normal PDF and quantile function.The AVaR deviation is:$$\mathcal{D}_p(Q \mid \mathbf{y})= \mathrm{AVaR}_p(Q \mid \mathbf{y}) - \mathbb{E}[Q \mid \mathbf{y}]= \sqrt{\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top} \cdot \frac{\phi(\Phi^{-1}(p))}{1 - p}.$$This is again **deterministic**, depending on $\mathbf{y}$ only through thefixed posterior variance $\sigma_Q^2$. The expected AVaR deviation is:$$\mathbb{E}\!\left[\mathcal{D}_p(Q \mid \mathbf{y})\right]= \sqrt{\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top} \cdot \frac{\phi(\Phi^{-1}(p))}{1 - p}.$$## Standard Deviation DeviationFor completeness, the standard deviation deviation (which corresponds to$\mathcal{D}(X) = \mathrm{Std}(X)$ with no shift) is simply:$$\mathcal{D}_\mathrm{std}(Q \mid \mathbf{y})= \sqrt{\boldsymbol{\psi}\boldsymbol{\Sigma}_\star\boldsymbol{\psi}^\top}= \sigma_Q.$$This is the simplest deviation measure and is used as the benchmark in the[verification tutorial](boed_pred_usage.qmd).## Numerical VerificationWe verify the analytical expressions against Monte Carlo estimates.```{python}import numpy as npfrom scipy.stats import normfrom pyapprox.util.backends.numpy import NumpyBkdfrom pyapprox.expdesign.analytical import ( ConjugateGaussianOEDExpectedStdDev, ConjugateGaussianOEDExpectedAVaRDev,)np.random.seed(42)bkd = NumpyBkd()# Build a small linear Gaussian problemnobs, degree, noise_std, prior_std =3, 2, 0.5, 0.5from pyapprox.expdesign.benchmarks.linear_gaussian import _build_vandermondeobs_locations = bkd.linspace(-1.0, 1.0, nobs)A = _build_vandermonde(obs_locations, 0, degree, bkd)nparams = A.shape[1]prior_mean = bkd.zeros((nparams, 1))prior_cov = bkd.eye(nparams) * prior_std **2noise_cov = bkd.eye(nobs) * noise_std **2# QoI matrix: single prediction pointqoi_location = bkd.asarray([0.5])psi = _build_vandermonde(qoi_location, 0, degree, bkd) # (1, nparams)weights = bkd.ones((nobs, 1)) / nobs# Compute effective noise covariancew_flat = bkd.reshape(weights, (nobs,))eff_noise_cov = bkd.diag(noise_std**2/ w_flat)# Analytical std deviationutil_std = ConjugateGaussianOEDExpectedStdDev(prior_mean, prior_cov, psi, bkd)util_std.set_observation_matrix(A)util_std.set_noise_covariance(eff_noise_cov)sigma_Q = util_std.value()print(f"Analytical std deviation: {sigma_Q:.6f}")# AVaR deviation at p=0.9p =0.9util_avar = ConjugateGaussianOEDExpectedAVaRDev( prior_mean, prior_cov, psi, p, bkd,)util_avar.set_observation_matrix(A)util_avar.set_noise_covariance(eff_noise_cov)avar_dev_analytical = util_avar.value()print(f"AVaR deviation (p={p}): {avar_dev_analytical:.6f}")# Verify AVaR deviation formulaavar_formula = sigma_Q * norm.pdf(norm.ppf(p)) / (1- p)print(f"AVaR formula check: {avar_formula:.6f}")```## Key Takeaways- The posterior mean $\boldsymbol{\mu}_\star$ is a Gaussian random variable; its distribution is fully determined by $\mathbf{R}$, the prior, and the noise.- For linear Gaussian models, entropic risk, AVaR, and standard deviation deviations of the push-forward are all **deterministic** — they depend on $\mathbf{y}$ only through $\boldsymbol{\Sigma}_\star$, which is observation-independent.- This means the expected deviation equals the deviation itself, simplifying the optimization problem.- Numerical verification against these closed forms is the basis of the[usage tutorial](boed_pred_usage.qmd).## Exercises1. Show that $\mathbb{E}[\boldsymbol{\mu}_\star] = \boldsymbol{\mu}$ (the mean of the posterior mean equals the prior mean).2. Verify that $\mathbb{V}[\boldsymbol{\psi}\boldsymbol{\mu}_\star] = \boldsymbol{\psi}\mathbf{C}\boldsymbol{\psi}^\top$ reduces to $\boldsymbol{\psi}\boldsymbol{\Sigma}\boldsymbol{\psi}^\top$ as $\boldsymbol{\Gamma} \to 0$ (noiseless observations).3. For $p \to 1^-$, what happens to the AVaR deviation? Interpret this result.## Next Steps- [Risk-Aware Utility for Log-Normal Predictions](boed_pred_lognormal_analysis.qmd) — extending these results when the QoI is the exponential of a Gaussian- [Goal-Oriented OED: Convergence Verification](boed_pred_usage.qmd) — numerical verification of these analytical expressions