Kernels and Hyperparameters
Chapter 7 showed that a kernel is a statement about the unknown function, and Chapter 8 showed what that statement becomes once data arrive. Both chapters fixed the kernel and its hyperparameters by hand. Each figure had a lengthscale slider, and moving it changed the predictions and the uncertainty everywhere. A Bayesian optimizer has nobody to move the slider. It must choose the kernel's settings from the same handful of evaluations it is trying to learn the objective from.
This chapter is about that choice. Its center is the marginal likelihood: a single number that says how probable the observed data are under a given kernel and hyperparameters, and whose maximum is the usual answer to "which lengthscale?". Before it come the kernels there are to choose from; after it, the ways the answer misleads, and why it misleads more as the number of inputs grows.
9.1 The kernel family #
A stationary kernel depends on its inputs only through the distance between them (Section 7.5.1). The ones used in Bayesian optimization differ in a single respect: how smooth the functions they draw are.
9.1.1 The Matérn ladder #
The Matérn family has a smoothness parameter (Section 7.5.3). When is a half-integer, the kernel is an exponential times a polynomial, and three such values cover practice. Table 9.1 lists them with the RBF kernel, which is the limit .
| Kernel | Draws are | ||
|---|---|---|---|
| Matérn 1/2 (exponential) | continuous, nowhere differentiable | ||
| Matérn 3/2 | once differentiable | ||
| Matérn 5/2 | twice differentiable | ||
| RBF (squared exponential) | infinitely differentiable |
The formulas and the differentiability rule are standard (Rasmussen and Williams, 2006, sec. 4.2.1); differentiability is meant in the mean-square sense of Section 7.5.3. The parameter returns in Section 13.4.3, in the bounds on an optimizer's regret (its total shortfall from the best value available): the theory of Bayesian optimization is stated kernel by kernel.
Two kernels from Chapter 7 complete the set. The periodic kernel Equation (7.7) draws functions that repeat exactly. The linear kernel is the kernel of Bayesian linear regression (Example 7.1),
whose draws are lines (planes, for several inputs) with a random offset and slope, pivoting around the point . It is not stationary: its variance grows with the distance from .
9.1.2 Sums and products #
Kernels can be combined, and the two basic rules have short proofs.
The sum of two kernels is a kernel. If and are independent, their sum is a Gaussian process with kernel (Exercise 7.3). A sum models a function made of independent parts: a slow trend plus a fast wiggle, or a signal plus correlated noise.
The product of two kernels is a kernel. The product of the same two processes has covariance (Exercise 9.1). The product process is not Gaussian, but its covariance function is positive semidefinite, which is all a kernel needs (Rasmussen and Williams, 2006, sec. 4.2.4). A product is large only when both factors are, so it models structure that must hold in both senses at once: a periodic kernel times an RBF kernel says "repeats, and nearby repetitions resemble each other more than distant ones".
A product is also how one kernel covers several inputs. If acts on the first input and on the second, is a kernel on pairs. The RBF kernel on several inputs is exactly such a product of one-dimensional RBF kernels, since the exponential of a sum is a product of exponentials. A sum across inputs, , says instead that the function is a sum of one function per input, with no interaction between them, which is a much stronger assumption.
The figure puts the family side by side. Each panel draws two functions, and every panel uses the same random numbers, so what differs between panels is the kernel alone.
Read the first four panels in order. The Matérn draws have the same large-scale shape, because the random numbers are shared, and lose their roughness one step at a time. The Matérn 5/2 draws are close to the RBF draws at first glance. The difference is in the tails of the kernel curve under each panel and in the fine detail of the draws.
Switch to Sums and products. A long RBF plus a short one gives a slow drift with a fast wiggle on top. An RBF plus a periodic kernel gives a repeating pattern riding on a trend. Their product gives a pattern that repeats but slowly changes shape. A linear kernel times itself draws parabolas, and times a periodic kernel it draws oscillations whose size grows away from the center.
A real example shows what composition buys. The monthly concentration of carbon dioxide measured at Mauna Loa, Hawaii, 545 observations from 1958 to 2003, is a standard demonstration (Rasmussen and Williams, 2006, sec. 5.4.3). The kernel used there is a sum of four parts, each built for one feature of the record: an RBF kernel for the long-term rise, a periodic kernel multiplied by an RBF for a seasonal cycle that may slowly change, a third term for irregularities over a few years, and a noise term. It has 11 hyperparameters, all fitted by the method of Section 9.3. The fitted values read like a report on the data: the trend has a lengthscale of 67 years, and the seasonal pattern decays over 90 years, so it is close to exactly periodic. The search for such structure can itself be automated by adding and multiplying base kernels greedily, scoring each candidate with its marginal likelihood (Duvenaud et al., 2013).
Bayesian optimization rarely goes that far. With a few dozen evaluations there is too little data to choose among structures, so the usual model is one Matérn 5/2 or RBF kernel with a separate lengthscale for each input. That last ingredient deserves its own section.
Sources cited in Section 9.1 2
- Rasmussen and Williams (2006) Gaussian Processes for Machine Learning
- Duvenaud et al. (2013) Structure Discovery in Nonparametric Regression through Compositional Kernel Search
9.2 One lengthscale per input #
An objective with several inputs seldom depends on all of them equally. A neural network's validation error may swing with one setting of its training procedure, the learning rate, and barely move with another. A single lengthscale cannot say that. It claims the function varies at the same rate in every direction.
The remedy is to measure distance with a ruler per input. Replace the squared distance by a sum of per-input terms:
where is the number of inputs, and likewise inside any Matérn kernel, with and in Table 9.1. Each says how far one must move along input before the function changes appreciably. A short means the function is sensitive to input . As grows, the term for input vanishes from the sum, the kernel stops noticing differences in that input, and every function the prior draws becomes constant along it. The input has been switched off without being removed.
Because the lengthscales are fitted to data, the model can discover which inputs matter. This is called automatic relevance determination (ARD), a term due to Neal (1996), and the inverse lengthscale is read as the relevance of input (Rasmussen and Williams, 2006, sec. 5.1).
Set both lengthscales to 0.2. The map is a landscape of round hills and hollows about 0.2 across, and the two cuts wiggle equally.
Lengthen to 5. The hills stretch into stripes that run along . The cut along is nearly a horizontal line. The function is still random, but it is a function of alone.
Press Swap the lengthscales. The stripes turn by a quarter turn. Which input matters is a property of the kernel, not of the random numbers.
Real tuning problems rely on this. Snoek et al. (2012) proposed the ARD Matérn 5/2 kernel for tuning machine learning models. With the Gaussian process model of their paper they tuned nine hyperparameters of a convolutional network on the CIFAR-10 image benchmark, and reached a test error of 14.98%, more than three percentage points better than the settings an expert had found. In the seven-hyperparameter problem of Section 22.4, two of the seven account for most of the variation in the error (Section 22.4.1), which is the situation ARD is meant for. Figure 9.4 in Section 9.5 shows fitted lengthscales separating six inputs that matter from fourteen that do not.
ARD has a price: one more hyperparameter per input, each to be learned from the same few evaluations. With real numbers as observations that is usually affordable. When each observation is a single comparison between two options, as in Part IV, it may not be: Chapter 25 fixes its six lengthscales instead of learning them, and Section 30.3.3 reports that no study has checked whether they can be learned at such budgets. In the other direction, a model that needs a much shorter lengthscale along one attribute than along the others is how a smooth utility approximates a person who attends to that attribute first (Section 37.5.2).
Sources cited in Section 9.2 3
- Neal (1996) Bayesian Learning for Neural Networks
- Rasmussen and Williams (2006) Gaussian Processes for Machine Learning
- Snoek et al. (2012) Practical Bayesian Optimization of Machine Learning Algorithms
9.3 The marginal likelihood #
Write for all the hyperparameters together: the lengthscales, the amplitude , and the noise standard deviation . The question is how to choose from the data.
The obvious criterion fails. If we score a setting by how closely the posterior mean passes through the observations, the winner is always the shortest lengthscale and the smallest noise: that model bends through every point exactly. It also predicts nothing between the points (Section 8.2). A model that can fit anything has learned nothing.
Section 5.6 met this problem for the straight line and answered it with the model evidence: score a model by the probability it assigned to the observed data before seeing them. The same idea works here, and for a Gaussian process the probability has a closed form.
- The model of Section 8.3 is . By Definition 7.1, the function values at the observed inputs are Gaussian, , with .
- The noise is , independent of .
- The sum of independent Gaussian vectors is Gaussian, and their covariances add (Section 4.6.1, applied through Equation (4.9)). So with .
- The probability density of the data is this Gaussian's density Equation (4.5) evaluated at the observed : .
- Take the logarithm, and call the result .
This is the log marginal likelihood (Rasmussen and Williams, 2006, sec. 5.4.1). "Marginal" because the unknown function values have been summed out: step 3 is the integral done in one line. It is the formula Equation (5.11) of Section 5.6 with a kernel matrix in place of , and it depends on only through .
9.3.1 Two terms that pull apart #
A single observation shows the mechanism.
With one observation , is the number , the total variance the model expects, and
The first term rewards a large : an observation far from zero is unsurprising to a model that expects large values. The second term punishes it: a model that spreads its probability over a wide range gives each particular value less. Setting the derivative with respect to to zero gives . The best model expects values of the size it saw, no smaller and no larger. The data say nothing about how splits into signal and noise, and no single observation could.
With observations the two terms keep these roles. The data fit is the only term that contains the observed values. It is a squared distance of from zero, measured in the units the model expects (the Mahalanobis distance of Section 4.2.1), and it is least negative when the data vary the way the kernel says they should.
The complexity term contains no observed values at all. The determinant is the volume of the region where the model expects data to fall (Section 3.6), so the term charges the model for every data set it could have explained, whether or not it occurred. A short lengthscale makes the entries of nearly independent, nearly diagonal, and the volume as large as the variances allow. A long lengthscale ties the observations together, which flattens the region and shrinks the volume. For a fixed noise level, lengthening therefore relaxes the complexity charge while it tightens the data fit, because a stiffer function can match fewer data sets (Rasmussen and Williams, 2006, sec. 5.4.1). The maximum of their sum is the lengthscale at which the model is as simple as the data permit. This is the automatic Occam's razor of Section 5.6.1, and it needs no held-out data.
9.3.2 The surface #
The figure computes Equation (9.4) over a grid of lengthscales and noise levels for seven observations, with the amplitude fixed at .
Start where the figure opens. The ring sits on a local maximum: a lengthscale of 0.44 with noise 0.74. The fit on the right is a gentle downward slope, and the model attributes everything else to noise.
Press Go to the best pair. The ring jumps to a lengthscale of 0.075 and noise 0.23. Now the fit wiggles through the points and the band balloons between them. The log marginal likelihood rises from to , so this explanation is times more probable than the other. Seven points cannot decide between "a wiggly function measured precisely" and "a smooth function measured badly".
Drag the ring straight down from the best pair. The value barely changes: at noise 0.01 it is . Once the function passes through the points, the model cannot tell small noise from none, and the surface is a flat ridge.
Read the cut at the bottom while moving the lengthscale. At the opening noise level, the data-fit curve falls from to as the lengthscale grows from 0.05 to 2, and the complexity curve rises from to . Their sum is nearly flat between 0.1 and 0.44. Lower the noise to 0.23 and the data-fit curve becomes a cliff: at a lengthscale of 0.5 it is , because a stiff curve with little noise cannot be near these points.
Press Data: three points, then Data: ten points. With three points the maximum sits in the corner of the surface, and a wide region of short lengthscales and small noise is within a few hundredths of it. Three points say almost nothing about the lengthscale. With ten the surface has one compact peak, at a lengthscale of 0.13 and noise 0.27.
The same picture, for another seven observations, appears in the standard reference, with the lesson stated plainly: every local maximum is a particular interpretation of the data, and with so few points the model cannot confidently reject either (Rasmussen and Williams, 2006, sec. 5.4.1).
The marginal likelihood is the probability the model gave the observed data before seeing them. Fitting the data well is not enough; the model must also not have predicted many data sets that did not occur.
Sources cited in Section 9.3 1
- Rasmussen and Williams (2006) Gaussian Processes for Machine Learning
9.4 Fitting hyperparameters #
The standard practice is to choose the hyperparameters that maximize Equation (9.4). It is called type II maximum likelihood, or empirical Bayes: maximum likelihood applied to the settings of the prior instead of to the function itself (Section 5.6).
9.4.1 Climbing the surface #
A grid like the one in Figure 9.3 works for two hyperparameters and not for ten, so the maximum is found by following the gradient.
Let be one hyperparameter and write for , the matrix of entrywise derivatives.
- Two matrix derivative rules are needed (Petersen and Pedersen, 2012; Rasmussen and Williams, 2006, app. A.3): and , where , the trace, is the sum of a matrix's diagonal entries.
- Apply the first rule to the data-fit term of Equation (9.4): , with , the weights of Section 8.2.1.
- Apply the second rule to the complexity term: .
- A number equals its own trace, and for any two matrices whose products exist. Moving the last factor to the front, equals .
- Add steps 2 and 3.
The Cholesky factorization of Algorithm 8.1, which costs , gives , the log determinant (Section 3.6.1), and . After that each hyperparameter's derivative costs (Rasmussen and Williams, 2006, sec. 5.4.1). In practice an automatic differentiation library produces the gradient from the code that computes Equation (9.4).
Input: inputs scaled to the unit cube, standardized observations , a kernel family.
- Parametrize every positive hyperparameter by its logarithm, so the optimizer works on an unconstrained scale.
- Choose a starting point: unit amplitude, a small noise level, and lengthscales suited to the number of inputs (Section 9.5).
- Maximize Equation (9.4) with a quasi-Newton method such as L-BFGS, an optimizer that follows the gradient Equation (9.5) and estimates the curvature from how the gradient changes between steps.
- Repeat steps 2 and 3 from several other starting points, and keep the result with the highest marginal likelihood.
import numpy as np
from scipy.optimize import minimize
# x: observed inputs, y: standardized observations (one-dimensional arrays)
def neg_log_marginal(log_theta, x, y):
ell, sf, sn = np.exp(log_theta)
K = sf**2 * np.exp(-0.5 * (x[:, None] - x[None, :]) ** 2 / ell**2)
L = np.linalg.cholesky(K + (sn**2 + 1e-8) * np.eye(len(x)))
alpha = np.linalg.solve(L.T, np.linalg.solve(L, y))
return 0.5 * y @ alpha + np.log(np.diag(L)).sum() + 0.5 * len(x) * np.log(2 * np.pi)
starts = [np.log([0.1, 1.0, 0.1]), np.log([0.5, 1.0, 0.5]), np.log([0.03, 1.0, 0.3])]
fits = [minimize(neg_log_marginal, s, args=(x, y), method="L-BFGS-B") for s in starts]
ell, sf, sn = np.exp(min(fits, key=lambda f: f.fun).x)
The sum of the logarithms of the Cholesky diagonal is half the log determinant. Without a gradient function, SciPy differentiates numerically, which is adequate for three hyperparameters.
9.4.2 How the fit fails #
Figure 9.3 already contains the three ways this procedure misleads.
Several maxima. The restarts in step 4 exist because the surface can have more than one peak, and a gradient method finds the one nearest its starting point. With little data the peaks can be nearly level, and which one the optimizer reports is then an accident of where it started.
Flat directions. The ridge toward zero noise, and the plateau with three observations, are regions where the data do not determine a hyperparameter. An optimizer still returns a single number there. This is why a Bayesian optimization loop starts with a handful of evaluations chosen without the model (Section 11.4): the first fits are otherwise taken on a plateau.
Too many hyperparameters. Maximizing over is itself a form of fitting, and it can overfit. With one lengthscale per input and few evaluations, a setting that switches off most inputs can explain the data by chance, and the model then ignores inputs that matter. Section 9.5 shows this happening in fifty dimensions.
A fourth consequence is specific to optimization. The hyperparameters are refitted as evaluations arrive, so the model the acquisition function consults keeps changing, and the convergence guarantees for a fixed kernel no longer apply directly (Section 13.5.2).
9.4.3 Priors, and averaging instead of choosing #
Two refinements address these failures. The first is to place a prior on the hyperparameters and maximize the posterior,
which is maximum a posteriori (MAP) estimation. The prior adds a gentle slope to plateaus and ridges, so the optimizer has somewhere to go where the data are silent. BoTorch's default models carry such priors on their lengthscales (Meta Platforms, Inc., 2026k).
A prior on a lengthscale needs care, because what counts as vague depends on the scale it is stated on. A density that is flat over between 0.01 and 10 puts 90% of its probability above . A density that is flat over on the same range puts a third of its probability on each factor of ten. Neither is neutral (Section 2.3.3). Lengthscale priors are therefore usually given on the logarithmic scale, as log-normal distributions, or as gamma distributions with a stated mode.
The second refinement is not to choose at all. A fully Bayesian treatment averages predictions over the posterior of , usually by drawing samples of with a Markov chain method, which produces draws from a distribution known only up to a constant (Section 17.5), and averaging the acquisition function over them. Snoek et al. (2012) did this and found, on their tuning problems, that it beat a single fitted value. A plausible reason is that with few evaluations, uncertainty about the hyperparameters is a large part of the uncertainty about the objective (inference). The cost is one Cholesky factorization per sample at every step of the loop.
Sources cited in Section 9.4 4
- Petersen and Pedersen (2012) The Matrix Cookbook
- Rasmussen and Williams (2006) Gaussian Processes for Machine Learning
- Meta Platforms, Inc. (2026k) botorch/models/utils/gpytorch_modules.py
- Snoek et al. (2012) Practical Bayesian Optimization of Machine Learning Algorithms
9.5 Priors on lengthscales and dimension #
For years, Bayesian optimization was said to stop working beyond ten or twenty inputs. Between 2024 and 2026 the failure was traced to a mundane cause: the default prior on the lengthscale (Hvarfner et al., 2024; Xu et al., 2025b; Papenmeier et al., 2025b).
The arithmetic was done in Section 3.1.2 and Section 7.5.2. Two random points in the unit cube are about apart, so distances grow with while a prior whose typical lengthscale is, say, 0.5 stays where it is. In high dimension every pair of evaluations is then many lengthscales apart, every kernel value is close to zero, and the model sees a collection of unrelated points. Section 30.1.2 derives this and plots it.
The damage is done before any data can object. Equation (9.5) multiplies by , and for the RBF kernel the derivative of an entry is . When the kernel values are near zero, so is the gradient, and an optimizer started at a short lengthscale has no slope to climb (Exercise 9.4). Xu et al. (2025b) and Papenmeier et al. (2025b) identify these vanishing gradients, caused by the initial lengthscale, as a main reason for failure in high dimension.
The fix is to let the lengthscale's prior grow with the dimension. Hvarfner et al. (2024) scaled it with and found that standard Bayesian optimization then performed best on three of the five real tasks they tried, ahead of methods built specially for high dimension. BoTorch has used this prior for most of its models since version 0.12.0 (Meta Platforms, Inc., 2026e): a log-normal distribution with location and scale , with the fit started at the prior's mode (Meta Platforms, Inc., 2026k). That mode is about : 0.65 for ten inputs and 0.92 for twenty.
9.5.1 ARD at work in twenty dimensions #
The figure replays Bayesian optimization on a test problem with a known structure. The objective is the six-dimensional Hartmann function, a standard test function with several local maxima, hidden among inputs that do nothing: in twenty dimensions, six inputs matter and fourteen are decoys. The model is a Gaussian process with the ARD kernel Equation (9.3), refitted by MAP every five evaluations, under two priors: a fixed Gamma(2.4, 2.7) prior with mode 0.52 in every dimension, which is the default of BoTorch's preference model (Meta Platforms, Inc., 2026h), and the dimension-scaled prior above.
Read the bars at the bottom first. In the run shown, the model under the scaled prior ends with lengthscales between 0.25 and 0.56 for the six inputs that matter, and between 2.6 and 30 for the fourteen decoys, most of them near 20. The model was not given which inputs were which. The data are explained as well without the decoys, and the complexity term of Equation (9.4) is larger for the simpler explanation. That is automatic relevance determination doing what its name says.
Switch to the fixed prior. The six relevant lengthscales are similar, 0.39 to 0.70, but the decoys stop between 1.5 and 2.1. The prior is the reason: Gamma(2.4, 2.7) puts less than 5% of its probability above a lengthscale of 2, so under it a lengthscale long enough to switch an input off is improbable, where the scaled prior at twenty dimensions puts about 90% there (inference).
Now compare the regret curves, and change the acquisition search. Here the picture is less tidy, and worth reading honestly. In twenty dimensions, with the acquisition function maximized over uniform random candidates only, the two priors end level: a median regret of 0.29 for the fixed prior and 0.31 for the scaled one, against 1.26 for random search. Adding candidates near the best points found so far lowers both, to 0.16 and 0.08. In fifty dimensions the same change takes the fixed prior from 0.89 to 0.18 and the scaled prior from 1.21 to 0.18. In ten dimensions the fixed prior finishes ahead, 0.10 against 0.18. In these runs, how the acquisition function is maximized matters more than which prior is used (inference).
Go to fifty dimensions and look at the bars again. With the scaled prior, two of the six relevant inputs now have lengthscales near 15: the model has switched off inputs that matter. Eighty evaluations are too few to determine fifty lengthscales, and this is the overfitting of Section 9.4.2.
These runs are six seeds on one test function with a small budget, and they do not settle anything. They do agree with the state of the research. The diagnosis, that fixed lengthscale priors fail as the dimension grows, is shared by the papers above. Why the remedy works is disputed: Papenmeier et al. (2025b) argue that good results in very high dimension come from local search behavior more than from a well-fitted model. Section 30.1 and Section 30.2 follow the argument. As of September 2026, the defaults of the software for learning from comparisons have not changed: every preference package examined in Section 31.2 still uses a prior that ignores dimension.
Sources cited in Section 9.5 6
- Hvarfner et al. (2024) Vanilla Bayesian Optimization Performs Great in High Dimensions
- Xu et al. (2025b) Standard Gaussian Process is All You Need for High-Dimensional Bayesian Optimization
- Papenmeier et al. (2025b) Understanding High-Dimensional Bayesian Optimization
- Meta Platforms, Inc. (2026e) BoTorch CHANGELOG
- Meta Platforms, Inc. (2026k) botorch/models/utils/gpytorch_modules.py
- Meta Platforms, Inc. (2026h) BoTorch PairwiseGP source code pairwise_gp.py
9.6 Checking the model #
The marginal likelihood ranks models against each other. It does not say whether the best of them is any good. A kernel that cannot express the objective still has a maximum somewhere. Before an optimizer acts on a model's uncertainty, it is worth asking whether that uncertainty is honest, and the data already collected can answer.
The check is leave-one-out prediction. Remove observation , predict it from the other , and compare the prediction with what was observed. Repeating this for every sounds like separate fits, but for a Gaussian process with fixed hyperparameters all predictions come from one matrix.
- Under the model, . Predicting from the rest is conditioning this Gaussian on all coordinates but one.
- Section 4.5.2 showed that the conditional distribution can be read from the precision matrix : the conditional variance of coordinate is , and its conditional mean is .
- The sum over is the full sum minus its own term: .
- Substitute: the mean is .
These are the leave-one-out mean and variance for a noisy observation at (Rasmussen and Williams, 2006, sec. 5.4.2). Despite appearances does not depend on (Exercise 9.3). Three uses follow.
Calibration. The standardized residuals should look like draws from a standard normal distribution: about 95% of them within . Many large residuals mean the model is overconfident, typically a lengthscale too long or a noise level too small. Residuals all near zero mean it is underconfident, and the optimizer will explore more than it needs to.
A second opinion on the hyperparameters. The sum of the leave-one-out log densities, , can replace the marginal likelihood as the quantity to maximize. The marginal likelihood is the probability of the data assuming the model is right; the leave-one-out score estimates predictive performance whether or not it is, which has been argued to make it more robust when the kernel is wrong (Rasmussen and Williams, 2006, sec. 5.4.2).
Finding the point that does not fit. One residual far outside the rest marks an observation the model cannot reconcile with its neighbors: a failed run, a mistyped value, or a region where the function changes character.
Turn on Leave-one-out check in Figure 9.3 to see Equation (9.6). At the best pair, each observation's interval contains it or nearly does. Drag to a long lengthscale with small noise, and the intervals shrink to dashes that miss their points, the picture of overconfidence. Drag to a very short lengthscale and every interval spans the whole prior: the model predicts nothing about a point from its neighbors, which is honest and useless.
In optimization there is one more check, and it is the simplest. Plot the posterior mean against the observations along one input at a time, through the best point so far. A model whose band is narrow where no evaluation has been made, or wide between evaluations that agree, has hyperparameters worth a second look before its next suggestion is trusted.
The kernels of this chapter were chosen and fitted as recipes for covariance matrices; Chapter 10 looks at them as objects in their own right, the view in which the guarantees of Chapter 13 are stated.
Sources cited in Section 9.6 1
- Rasmussen and Williams (2006) Gaussian Processes for Machine Learning
9.7 Exercises #
Let and be independent, and define . (a) Show that . (b) Why does this prove that the product of two kernels is positive semidefinite, even though is not a Gaussian process?
Solution
(a) has mean zero, because by independence . So the covariance is , and independence splits the expectation into . (b) The argument of Section 7.2.2 used nothing about Gaussians: for any random function with finite variances, is the variance of and so cannot be negative. The covariance function of any random function is a valid kernel, and a Gaussian process with that kernel then exists by Definition 7.1.
Two noise-free observations under a unit-amplitude kernel have correlation . (a) Write the log marginal likelihood as a function of . (b) Suppose the two observed values are identical, . Show that the log marginal likelihood grows without bound as . What does the fitted model believe, and what does this say about fitting without a noise term or a prior?
Solution
(a) has determinant and inverse , so by Equation (9.4)
(b) With the numerator is , and since the data fit is , which stays between and . The complexity term tends to as . So the marginal likelihood is maximized by an infinite lengthscale: the model concludes that the function is constant, with certainty, from two equal values. Two equal values are weak evidence for that. A noise term, which keeps away from singular, or a prior on the lengthscale, keeps the optimizer from running off to this degenerate answer.
(a) Show that the leave-one-out mean of Equation (9.6) does not depend on . (b) For two observations with , compute and from Equation (9.6) and check them against the conditioning formula Equation (4.14), with , , and zero means.
Solution
(a) Write . Then , so , and the two cancel. (b) The inverse is . So , and . Equation (4.14), with the roles of the two coordinates exchanged, gives mean and variance , the same.
For the RBF kernel , the derivative with respect to the lengthscale is . (a) Write it as a function of the scaled distance , and find the at which it is largest. (b) Evaluate it, relative to that largest value, at the typical distance between two random points in when , and when .
Solution
(a) . Differentiating gives , which vanishes at , where the factor equals . A pair of points informs the lengthscale most when it is about 1.4 lengthscales apart. (b) The typical distance is (Section 3.1.2). With , and , about three millionths of the largest value. With , and the factor is , about 70% of the largest value. At the fixed lengthscale almost no pair of points carries a usable gradient; at the scaled one, typical pairs do.
Further reading #
- Rasmussen and Williams (2006), chapter 4, catalogs kernels and the rules for combining them; chapter 5 derives the marginal likelihood, its gradient, and the leave-one-out formulas, and works the Mauna Loa example in full.
- Garnett (2023), chapters 3 and 4, treats kernel choice, model assessment, and averaging over models with Bayesian optimization in mind.
- Snoek et al. (2012) is the paper that made the ARD Matérn 5/2 kernel and the fully Bayesian treatment of hyperparameters standard in Bayesian optimization.
- Duvenaud et al. (2013) searches over sums and products of kernels automatically, with the marginal likelihood as the score.
- Hvarfner et al. (2024) is the paper that traced the failure of standard Bayesian optimization in high dimension to the lengthscale prior.
- Neal (1996) introduced automatic relevance determination, for neural networks.
- Stein (1999) gives the theory behind preferring Matérn kernels to the RBF kernel.
References
- (2013). Structure Discovery in Nonparametric Regression through Compositional Kernel Search. Proceedings of the 30th International Conference on Machine Learning (ICML 2013). Cited in §9.1
- (2023). Bayesian Optimization. Cambridge University Press.
- (2024). Vanilla Bayesian Optimization Performs Great in High Dimensions. International Conference on Machine Learning. Cited in §9.5
- (2026e). BoTorch CHANGELOG. GitHub. software Cited in §9.5
- (2026h). BoTorch PairwiseGP source code pairwise_gp.py. GitHub. software Cited in §9.5
- (2026k). botorch/models/utils/gpytorch_modules.py. GitHub. software Cited in §9.4 §9.5
- (1996). Bayesian Learning for Neural Networks. Springer. Cited in §9.2
- (2025b). Understanding High-Dimensional Bayesian Optimization. ICML 2025, PMLR 267:47902-47923. Cited in §9.5
- (2012). The Matrix Cookbook. Technical University of Denmark. non-peer-reviewed Cited in §9.4
- (2006). Gaussian Processes for Machine Learning. MIT Press. Cited in §9.1 §9.2 §9.3 §9.4 §9.6
- (2012). Practical Bayesian Optimization of Machine Learning Algorithms. Advances in Neural Information Processing Systems 25 (NeurIPS 2012). Cited in §9.2 §9.4
- (1999). Interpolation of Spatial Data: Some Theory for Kriging. Springer.
- (2025b). Standard Gaussian Process is All You Need for High-Dimensional Bayesian Optimization. ICLR 2025 (oral). Cited in §9.5