Module contents
Lesson 6 of 27Core 110 min

Bayesian linear regression and the evidence approximation

Linear regression with basis functions is an ideal laboratory where everything is Gaussian and closed form. Derive posterior, predictive distribution and marginal likelihood, including unknown noise through a Normal-gamma prior; fit hyperparameters by maximizing evidence with MacKay updates; introduce automatic relevance determination; and discover the equivalent kernel leading to Gaussian processes.

After this lesson you can

  • Derive Bayesian linear regression posterior and predictive distribution as a linear Gaussian model.
  • Treat noise variance as unknown using a Normal-gamma prior and obtain the Student t predictive distribution.
  • Compute linear-model log evidence stably and use it to choose complexity.
  • Implement MacKay fixed-point updates for α and β and interpret effective parameter count γ.
  • Apply ARD for feature selection and explain its tendency toward sparsity.
  • Express the predictive mean using the equivalent kernel.

Before you start

Fit a line and retain uncertainty

A point prediction does not say which other lines are compatible with data. Bayesian linear regression assigns a prior to weights and obtains a posterior distribution. Basis functions can be nonlinear in the input: “linear” means linear in the weights.

For NN observations, let Φ\mat\Phi be the matrix with rows ϕ(xi)⊤\boldsymbol\phi(x_i)\T and MM columns. Use Gaussian prior and likelihood with positive precisions α\alpha and β\beta:

w∼N(0,α−1I),y∣w∼N(Φw,β−1I).\vb w\sim\Normal(\vb0,\alpha^{-1}\mat I),\quad \vb y\given\vb w\sim\Normal(\mat\Phi\vb w,\beta^{-1}\mat I).

Completing the square in the exponent gives p(w∣y)=N(m,S)p(\vb w\given\vb y)=\Normal(\vb m,\mat S), where

A=αI+βΦ⊤Φ,S=A−1,m=βSΦ⊤y.\mat A=\alpha\mat I+\beta\mat\Phi\T\mat\Phi,\quad \mat S=\mat A^{-1},\quad \vb m=\beta\mat S\mat\Phi\T\vb y.

To see why, collect terms depending on w\vb w: the exponent is minus one half of w⊤Aw−2βw⊤Φ⊤y\vb w\T\mat A\vb w-2\beta\vb w\T\mat\Phi\T\vb y plus a constant. Substituting Am=βΦ⊤y\mat A\vb m=\beta\mat\Phi\T\vb y writes it as (w−m)⊤A(w−m)(\vb w-\vb m)\T\mat A(\vb w-\vb m) plus a constant. The matrix multiplying the centered square is precision; its inverse is covariance. Each observation contributes βϕiϕi⊤\beta\boldsymbol\phi_i\boldsymbol\phi_i\T to precision, a positive-semidefinite matrix. Thus with β\beta fixed, covariance does not increase in any direction as data is added.

In practice solve systems with Cholesky: A\mat A is positive definite because α>0\alpha>0. The mean also minimizes ∥y−Φw∥2+(α/β)∥w∥2\|\vb y-\mat\Phi\vb w\|^2+(\alpha/\beta)\|\vb w\|^2; this is ridge with penalty α/β\alpha/\beta. If a column of ones is included, this formulation also penalizes the intercept. Column scaling matters: an isotropic prior assigns the same scale to all weights, not to original variables irrespective of their units.

InteractiveUpdate weights point by point

Weight plane (w₀,w₁)

Click here to add data

  • weight prior and posterior
  • last-observation band: ±1 standard deviation
  • sampled lines

Prior N(0,I), noise standard deviation 0.5 and model y=w₀+w₁x. The two initial points are synthetic and editable; lines use eight normal samples with a fixed seed. The band is the likelihood of the last point, not a posterior region.

0.0
0.0
Observations2
Weight mean0.21 · 0.91
Covariance trace0.246
Add observations and follow the posterior, the last point's likelihood band and sampled lines.

In the figure the initial prior is N(0,I)\Normal(0,\mat I) and noise standard deviation is 0.5. The posterior ellipse contains 95 % of the bivariate distribution; lines are eight samples, not predictive intervals. An observation constrains combination w0+xw1w_0+xw_1, producing a likelihood band. Points at different inputs constrain different directions. Repeating an input reduces uncertainty about one combination but does not alone identify both weights.

In the simplest one-dimensional case, with ϕi=1\phi_i=1 for every row, posterior precision is α+Nβ\alpha+N\beta and mean is β∑iyi/(α+Nβ)\beta\sum_i y_i/(\alpha+N\beta). This mean is the sample mean multiplied by Nβ/(α+Nβ)N\beta/(\alpha+N\beta): it approaches zero when the prior dominates and the sample mean when data information dominates. Posterior variance of the mean, 1/(α+Nβ)1/(\alpha+N\beta), decreases with NN, whereas future-observation variance additionally includes β−1\beta^{-1}.

To incorporate (ϕ,y)(\boldsymbol\phi,y) without reprocessing old data, use the current posterior as prior:

Sn+1−1=Sn−1+βϕϕ⊤,mn+1=Sn+1(Sn−1mn+βϕy).\mat S_{n+1}^{-1}=\mat S_n^{-1}+\beta\boldsymbol\phi\boldsymbol\phi\T,\qquad \vb m_{n+1}=\mat S_{n+1}(\mat S_n^{-1}\vb m_n+\beta\boldsymbol\phi y).

With fixed hyperparameters and conditionally independent observations, this matches joint fitting. Changing α\alpha or β\beta after each observation breaks that equivalence unless earlier data is reconsidered under the new values.

Prediction and unknown noise

Integrating weights gives, for a new input,

y∗∣y∼N(ϕ∗⊤m,  β−1+ϕ∗⊤Sϕ∗).y_*\given\vb y\sim\Normal(\boldsymbol\phi_* \T\vb m,\; \beta^{-1}+\boldsymbol\phi_*\T\mat S\boldsymbol\phi_*).

The first term represents noise in a future observation; the second represents uncertainty about the mean. A latent-function band uses only the second. Even when the weight posterior concentrates, noise in a new observation remains. This conclusion requires sufficiently informative data in the direction of ϕ∗\boldsymbol\phi_* and a fixed model; it does not follow merely from counting data in regions uninformative about that direction.

The law of total variance explains the separation. Conditional on weights, the mean of y∗y_* is ϕ∗⊤w\boldsymbol\phi_*\T\vb w and variance is β−1\beta^{-1}. Averaging over the posterior leaves the first contribution β−1\beta^{-1}, while variation of conditional means is ϕ∗⊤Sϕ∗\boldsymbol\phi_*\T\mat S\boldsymbol\phi_*. A point prediction uses the posterior mean; an interval for a future observation needs both parts. Intervals are conditional on the model, prior and chosen precisions.

InteractiveThe predictive band and its limits
  • Mean and 95 % predictive
  • Synthetic data

Sixteen synthetic sin(2x) observations with noise standard deviation 0.18 and a fixed seed. Basis centers lie between −2 and 2; the band includes weight uncertainty and assumed noise. The line joining the data only helps locate them.

1.0
25
0.5
Parameter variance at x=62.00e-29
Noise variance0.040
Change precisions and the width of nine localized Gaussian bases.

With these bases, ϕ(x)\boldsymbol\phi(x) approaches the zero vector far from every center. The mean and parameter variance also approach zero there, even without observations. β−1\beta^{-1} remains. This follows from the chosen function prior, not proof that extrapolation is reliable. Adding a constant basis or another prior changes the behavior.

If noise precision β\beta is unknown, a coherent conjugate family also scales the weight-prior covariance:

β∼Gamma⁡(a0,b0),w∣β∼N(m0,(βΛ0)−1),\beta\sim\operatorname{Gamma}(a_0,b_0),\quad \vb w\given\beta\sim\Normal(\vb m_0,(\beta\mat\Lambda_0)^{-1}),

where Gamma uses shape and rate. For Λn=Λ0+Φ⊤Φ\mat\Lambda_n=\mat\Lambda_0+\mat\Phi\T\mat\Phi,

mn=Λn−1(Λ0m0+Φ⊤y),an=a0+N/2,\vb m_n=\mat\Lambda_n^{-1}(\mat\Lambda_0\vb m_0+\mat\Phi\T\vb y),\quad a_n=a_0+N/2, bn=b0+12(y⊤y+m0⊤Λ0m0−mn⊤Λnmn).b_n=b_0+\tfrac12(\vb y\T\vb y+\vb m_0\T\mat\Lambda_0\vb m_0- \vb m_n\T\mat\Lambda_n\vb m_n).

The posterior remains Normal-gamma. Integrating w\vb w and β\beta, y∗y_* has a Student t distribution with 2an2a_n degrees of freedom, location ϕ∗⊤mn\boldsymbol\phi_*\T\vb m_n and squared scale (bn/an)(1+ϕ∗⊤Λn−1ϕ∗)(b_n/a_n)(1+\boldsymbol\phi_*\T\mat\Lambda_n^{-1}\boldsymbol\phi_*). A t scale is not its variance: the latter is squared scale multiplied by an/(an−1)a_n/(a_n-1) if an>1a_n>1. This joint family is not the same independent prior on w\vb w and β\beta used above.

For example, in one dimension take m0=0m_0=0, Λ0=1\Lambda_0=1, a0=2a_0=2, b0=1b_0=1 and observe ϕ=1\phi=1, y=2y=2. Then Λn=2\Lambda_n=2, mn=1m_n=1, an=2.5a_n=2.5 and bn=2b_n=2. For a new input with ϕ∗=1\phi_*=1, the predictive distribution has five degrees of freedom, location 1 and squared scale 1.2. Its variance is 2: confusing scale and variance misinterprets the interval. If an≤1a_n\le1, t variance does not exist even though the predictive distribution remains proper.

Evidence is also closed form in this joint model:

p(y)=(2π)−N/2∣Λ0∣1/2∣Λn∣1/2b0a0bnanΓ(an)Γ(a0).p(\vb y)= (2\pi)^{-N/2} \frac{|\mat\Lambda_0|^{1/2}}{|\mat\Lambda_n|^{1/2}} \frac{b_0^{a_0}}{b_n^{a_n}}\frac{\Gamma(a_n)}{\Gamma(a_0)}.

Completing the square first integrates the conditional normal over weights; the determinant ratio comes from its normalization constants. The remaining integral is the normalization of a Gamma with shape ana_n and rate bnb_n. In computation use log determinants and log-Gamma. The predictive t follows as ratio p(y,y∗)/p(y)p(\vb y,y_*)/p(\vb y) or by integrating the conditional predictive normal against the Gamma posterior. Its heavier tails reflect remaining uncertainty about noise scale.

Evidence and complexity

Evidence approximation estimates hyperparameters by maximizing marginal probability of the same data after integrating weights. This is empirical Bayes: it does not integrate posterior uncertainty in those hyperparameters. Here the integral is exact for fixed values:

C=β−1I+α−1ΦΦ⊤,log⁡p(y∣α,β)=−12[Nlog⁡(2π)+log⁡∣C∣+y⊤C−1y].\mat C=\beta^{-1}\mat I+\alpha^{-1}\mat\Phi\mat\Phi\T,\qquad \log p(\vb y\given\alpha,\beta) =-\tfrac12[N\log(2\pi)+\log|\mat C|+\vb y\T\mat C^{-1}\vb y].

The quadratic measures fit and the determinant normalizes the volume of possible predictions. A flexible family spreads probability over more outcomes; it can fit a dataset better yet have lower evidence. The so-called Occam factor depends on the prior, not a universal penalty by parameter count. Calculate log⁡∣C∣\log|\mat C| as twice the sum of logarithms of the Cholesky diagonal and solve for C−1y\mat C^{-1}\vb y without inversion.

InteractiveEvidence versus degree

Detail for degrees 1 to 7

Twenty-four synthetic cubic observations with noise standard deviation 0.3. Evidence uses α=1 and β=1/0.3²; MSE comes from almost unregularized least squares and is a different measure. The decomposition sums exactly the two displayed terms.

3
Almost unpenalized training MSE0.0531
Log evidence-9.74
Fit term-8.71
Normalization and determinant-1.03
Degree with highest evidence3
Compare training error with almost no penalty against evidence under a fixed prior.

The figure’s 24 observations come from a cubic polynomial plus synthetic noise. Polynomial spaces are nested, so the ordinary least-squares minimum does not increase as degrees are added. The figure approximates that minimum with a tiny penalty; it does not claim training error of a ridge posterior with fixed penalty must be monotonic. Evidence and the displayed MSE use different criteria. Compare evidence only when models assign density to the same data, units and response transformation.

Let λj\lambda_j be an eigenvalue of βΦ⊤Φ\beta\mat\Phi\T\mat\Phi. The effective parameter count is

γ=∑j=1Mλjα+λj.\gamma=\sum_{j=1}^{M}\frac{\lambda_j}{\alpha+\lambda_j}.

Each direction informed by data contributes near one; one dominated by the prior contributes near zero. At an interior evidence optimum without hyperpriors, MacKay’s equations are

α=γm⊤m,β=N−γ∥y−Φm∥2.\alpha=\frac{\gamma}{\vb m\T\vb m},\qquad \beta=\frac{N-\gamma}{\|\vb y-\mat\Phi\vb m\|^2}.

Iterating them is a fixed-point search, not a guarantee of a global optimum or monotonic improvement at every step. Zero denominators, boundary solutions and ill-conditioning need attention. Gamma hyperpriors add terms. The lab uses them explicitly to compare with scikit-learn; there the library calls our prior precision λ\lambda and noise precision α\alpha.

γ\gamma has a spectral interpretation: when a weight direction has high likelihood curvature relative to prior precision, its data determine nearly one complete parameter. A direction without curvature contributes zero, even if it is a matrix column. Thus γ\gamma lies between zero and MM for positive precisions. The equations balance mean norm against effective dimension and residual against remaining degrees of freedom. Do not replace MM by column count without checking as though all columns were equally identified.

Automatic relevance and the kernel

Automatic relevance determination assigns a distinct precision αj\alpha_j to each weight. As one precision grows, prior and posterior shrink that coordinate toward zero. This can produce sparse solutions, but maximizing many precisions can also overfit, especially with correlated features. High precision does not prove causality or guarantee recovery of every true variable.

InteractiveARD and precisions
-1.00.01.02.03.04.05.06.01-0.62-0.230.344.253.264.073.984.394.2102.9log₁₀ precision

Synthetic data with 80 rows, ten normal features, true weights (2, −1.3, 0.7, 0, …) and noise standard deviation 0.35. Small hyperpriors are used and no feature is removed automatically; high precision concentrates its weight near zero. Perfect selection is not guaranteed.

iteration 40
Weights of the first three1.97 · -1.25 · 0.72
Precisions above 1007
Follow updates for ten synthetic features, three carrying signal.

The example uses small hyperpriors and shows finite precisions; it does not automatically prune. Practical implementations may remove coordinates above a threshold. The relevance vector machine applies this kind of prior to weights of basis functions associated with examples and often obtains a sparse representation; selection and probabilities depend on the model and fitting procedure, not a guarantee of generalization.

The same prediction can be expressed in function space. The finite prior’s equivalent kernel is k(x,x′)=α−1ϕ(x)⊤ϕ(x′)k(x,x')=\alpha^{-1}\boldsymbol\phi(x)\T\boldsymbol\phi(x'). If K=α−1ΦΦ⊤\mat K=\alpha^{-1}\mat\Phi\mat\Phi\T and k∗=α−1Φϕ∗\vb k_*=\alpha^{-1}\mat\Phi\boldsymbol\phi_*, then

E[y∗∣y]=k∗⊤(K+β−1I)−1y.\mathbb E[y_*\given\vb y]=\vb k_*\T(\mat K+\beta^{-1}\mat I)^{-1}\vb y.

This equals ϕ∗⊤m\boldsymbol\phi_*\T\vb m by the linear-system identity. The kernel has rank at most MM on any finite set. It shows that a prior on weights induces one on functions and prepares the transition to Gaussian processes; basis choice still determines behavior far from data.

Weight-space computation factorizes a matrix of size MM; data space uses one of size NN. The suitable alternative depends on dimensions and available structure. The noise term makes the data-space matrix positive definite even if the finite kernel is rank deficient. With a different kernel and prior, uncertainty outside the observed region may behave differently: the formula alone does not decide which extrapolation is credible.

Lab: fit and check

The next engine computes posterior, predictive distribution and evidence and applies fixed points with hyperprior terms 10−610^{-6} in scikit-learn’s parameterization. Each update adds 2⋅10−62\cdot10^{-6} to numerator and denominator. It uses Cholesky; full covariance is formed only because the example is small.

[ ]Bayesian linear regression from scratchBrowser
"""Regresión lineal bayesiana y puntos fijos de evidencia."""
import numpy as np
from scipy.linalg import cho_factor,cho_solve


def posterior(X,y,alpha,beta):
    X=np.asarray(X,float);y=np.asarray(y,float)
    if alpha<=0 or beta<=0:raise ValueError('precisiones deben ser positivas')
    A=alpha*np.eye(X.shape[1])+beta*X.T@X
    factor=cho_factor(A,lower=True)
    covariance=cho_solve(factor,np.eye(X.shape[1]))
    mean=cho_solve(factor,beta*X.T@y)
    return mean,covariance


def predictive(X_new,mean,covariance,beta):
    X_new=np.asarray(X_new,float)
    return X_new@mean,1/beta+np.einsum('ij,jk,ik->i',X_new,covariance,X_new)


def log_evidence(X,y,alpha,beta):
    X=np.asarray(X,float);y=np.asarray(y,float)
    if alpha<=0 or beta<=0:raise ValueError('precisiones deben ser positivas')
    C=([email protected])/alpha+np.eye(len(y))/beta
    factor=cho_factor(C,lower=True)
    logdet=2*np.log(np.diag(factor[0])).sum()
    return -.5*(len(y)*np.log(2*np.pi)+logdet+y@cho_solve(factor,y))


def mackay(X,y,steps=500,tol=1e-10,hyper=1e-6):
    """alpha prior, beta ruido. hyper=1e-6 reproduce hiperpriors de sklearn."""
    X=np.asarray(X,float);y=np.asarray(y,float)
    alpha=1.;beta=1/(np.var(y)+np.finfo(float).eps)
    eig=np.linalg.eigvalsh(X.T@X);previous=None;history=[]
    for _ in range(steps):
        mean,cov=posterior(X,y,alpha,beta)
        gamma=np.sum(beta*eig/(alpha+beta*eig))
        rss=np.sum((y-X@mean)**2)
        alpha=(gamma+2*hyper)/(mean@mean+2*hyper)
        beta=(len(y)-gamma+2*hyper)/(rss+2*hyper)
        history.append((alpha,beta,gamma))
        if previous is not None and np.sum(abs(mean-previous))<tol:break
        previous=mean.copy()
    mean,cov=posterior(X,y,alpha,beta)
    return mean,cov,alpha,beta,np.array(history)


def ard(X,y,steps=1000,tol=1e-8,hyper=1e-6,threshold=1e10):
    """ARD diagonal con poda por precisión y los hiperpriors declarados."""
    X=np.asarray(X,float);y=np.asarray(y,float);n,d=X.shape
    beta=1/(np.var(y)+np.finfo(float).eps);alpha=np.ones(d);keep=np.ones(d,bool)
    previous=None;history=[];mean=np.zeros(d)
    for _ in range(steps):
        ids=np.flatnonzero(keep)
        if not len(ids):break
        A=np.diag(alpha[ids])+beta*X[:,ids].T@X[:,ids]
        factor=cho_factor(A,lower=True);cov=cho_solve(factor,np.eye(len(ids)))
        mean=np.zeros(d);mean[ids]=cho_solve(factor,beta*X[:,ids].T@y)
        rss=np.sum((y-X@mean)**2)
        gamma=1-alpha[ids]*np.diag(cov)
        alpha[ids]=(gamma+2*hyper)/(mean[ids]**2+2*hyper)
        beta=(n-gamma.sum()+2*hyper)/(rss+2*hyper)
        keep=alpha<threshold;mean[~keep]=0
        history.append((alpha.copy(),beta))
        if previous is not None and np.sum(abs(previous-mean))<tol:break
        previous=mean.copy()
    ids=np.flatnonzero(keep);mean=np.zeros(d);cov=np.zeros((d,d))
    if len(ids):
        A=np.diag(alpha[ids])+beta*X[:,ids].T@X[:,ids]
        factor=cho_factor(A,lower=True);cov[np.ix_(ids,ids)]=cho_solve(factor,np.eye(len(ids)))
        mean[ids]=cho_solve(factor,beta*X[:,ids].T@y)
    return mean,cov,alpha,beta,history

The comparison uses 80 synthetic rows, ten independent normal columns, three nonzero weights and noise standard deviation 0.35. Disable the extra intercept and set the ARD threshold so both implementations retain the same coordinates. A run’s numerical values are not universal ARD properties.

[ ]Compare with scikit-learnBrowser
from sklearn.linear_model import BayesianRidge, ARDRegression
rng=np.random.default_rng(123)
X=rng.normal(size=(80,10)); truth=np.array([2.,-1.3,.7]+[0.]*7)
y=X@truth+.35*rng.normal(size=80)
m,S,alpha,beta,h=mackay(X,y)
ref=BayesianRidge(fit_intercept=False,max_iter=500,tol=1e-10).fit(X,y)
print("precisiones prior, ruido (propias):",alpha,beta)
print("precisiones prior, ruido (sklearn):",ref.lambda_,ref.alpha_)
print("error máximo de medias:",np.max(abs(m-ref.coef_)))
ma,Sa,aa,ba,ha=ard(X,y)
ar=ARDRegression(fit_intercept=False,max_iter=1000,tol=1e-8,threshold_lambda=1e10).fit(X,y)
print("precisiones ARD propias:",aa)
print("precisiones ARD sklearn:",ar.lambda_)
print("error relativo máximo:",np.max(abs(aa-ar.lambda_)/ar.lambda_))
assert np.allclose(m,ref.coef_,atol=1e-7)
assert np.allclose([alpha,beta],[ref.lambda_,ref.alpha_],rtol=1e-6)
assert np.allclose(aa,ar.lambda_,rtol=1e-5)
print("media y varianza predictiva de dos filas:",predictive(X[:2],m,S,beta))

The next experiment generates 200 independent samples of size 30 from a cubic polynomial, known noise 0.3 and seed 2026. Compare degrees 0 through 5 with a fixed prior and five-fold cross-validation. The measure is frequency of recovering the generating degree, not future predictive error. Times belong to this run and depend on the environment; they are not a general cost comparison.

[ ]Two hundred degree comparisonsBrowser
import time, numpy as np
rng=np.random.default_rng(2026);n=30;sigma=.3;alpha=1.;beta=1/sigma**2
x=np.linspace(-1,1,n);true=np.array([.4,1.,-.5,1.5]);degrees=range(6)
matrices=[np.vander(x,d+1,increasing=True) for d in degrees]
truth=matrices[3]@true;fold=np.arange(n)%5
choice_e=[];choice_cv=[];times_e=times_cv=0.
for rep in range(200):
    y=truth+sigma*rng.normal(size=n)
    t=time.perf_counter();scores=[log_evidence(X,y,alpha,beta) for X in matrices]
    choice_e.append(int(np.argmax(scores)));times_e+=time.perf_counter()-t
    t=time.perf_counter();loss=[]
    for X in matrices:
        errors=[]
        for k in range(5):
            train=fold!=k;mean,_=posterior(X[train],y[train],alpha,beta)
            errors.extend((y[~train]-X[~train]@mean)**2)
        loss.append(np.mean(errors))
    choice_cv.append(int(np.argmin(loss)));times_cv+=time.perf_counter()-t
print('200 experiments evidence/CV correct:',np.mean(np.array(choice_e)==3),np.mean(np.array(choice_cv)==3))
print('degree frequency evidence:',np.bincount(choice_e,minlength=6),'CV:',np.bincount(choice_cv,minlength=6))
print('elapsed cumulative seconds evidence/CV:',times_e,times_cv)

Evidence uses the fixed prior for comparison; changing that prior or candidate family can change the ranking. Cross-validation fits the same model on each training split and evaluates held-out data. Selecting a degree using data does not turn evaluation on those same data into an unbiased generalization measure.

In the reproduced run with that seed, evidence chooses cubic degree in 154 of 200 datasets and cross-validation in 115. Evidence chooses degrees four and five in the other 46; cross-validation chooses them in the other 85. These are frequencies for this design and family, not a claim that one criterion is always better. Printed cost separately sums each criterion’s evaluation time; it includes five cross-validation fits per degree and excludes data creation. Measurements vary across machines and runs.

Exercises

ProofIntegrate the weights
Prove: Derive the marginal Gaussian distribution of observations.
0
w and noise are independent normals with covariances I/α and I/β.

Step 1 of 3. What is the mean of Φw+ε?

ProofStationarity of α
Prove: Prove α=γ/(mᵀm) at an interior optimum without a hyperprior.
0
A=αI+βΦᵀΦ and S=A⁻¹. Differentiate log evidence, accounting for m optimizing the exponent.

Step 1 of 3. What is the derivative of log|A| with respect to α?

Numeric
For α=1 and eigenvalues of βΦᵀΦ equal to 100, 10, 1 and 0.1, calculate γ.
CodeGaussian log evidence
Implement log_ev(X,y,alpha,beta) for positive precisions using Cholesky of C=I/beta+X Xᵀ/alpha. Return the log marginal density.
import numpy as np
def log_ev(X,y,alpha,beta):
  return None
Shift+Enter to run
Quiz
In a fixed model, if data make weight uncertainty vanish in the new input's direction, what happens to predictive variance?
Key idea
The posterior separates weight uncertainty from predictive noise; evidence compares models under specific priors, and ARD adapts precisions without removing the need for validation.

References