ArticleslgStudy

computer science

Bayesian quadrature

Bayesian quadrature is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bayesian quadrature rather than just read about it. In short: Bayesian quadrature is a method for approximating intractable integration problems. It falls within the class of probabilistic numerical methods.

Bayesian quadrature — main illustration
Bayesian quadrature — illustration

Key takeaways

  • Bayesian quadrature belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bayesian quadrature to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bayesian quadrature from memory before moving on to harder problems.

Reference excerpt

Bayesian quadrature is a method for approximating intractable integration problems. It falls within the class of probabilistic numerical methods. Bayesian quadrature views numerical integration as a Bayesian inference task, where function evaluations are used to estimate the integral of that function. For this reason, it is sometimes also referred to as "Bayesian probabilistic numerical integration" or "Bayesian numerical integration". The name "Bayesian cubature" is also sometimes used when the integrand is multi-dimensional. A potential advantage of this approach is that it provides probabilistic uncertainty quantification for the value of the integral.

Bayesian quadrature

Numerical integration Let f:𝒳→ℝ be a function defined on a domain 𝒳 (where typically 𝒳⊆ℝd). In numerical integration, function evaluations f(x1),…,f(xn) at distinct locations x1,…,xn in 𝒳 are used to estimate the integral of f against a measure ν: i.e. ν[f]:=∫𝒳f(x)ν(dx). Given weights w1,…,wn∈ℝ, a quadrature rule is an estimator of ν[f] of the form ν̂[f]:=∑i=1nwif(xi). Bayesian quadrature consists of specifying a prior distribution over f, conditioning this prior on f(x1),…,f(xn) to obtain a posterior distribution f, then computing the implied posterior distribution on ν[f]. The name "quadrature" comes from the fact that the posterior mean on ν[f] sometimes takes the form of a quadrature rule whose weights are determined by the choice of prior.

Bayesian quadrature with Gaussian processes The most common choice of prior distribution for f is a Gaussian process as this permits conjugate inference to obtain a closed-form posterior distribution on ν[f]. Suppose we have a Gaussian process with prior mean function m:𝒳→ℝ and covariance function (or kernel function) k:𝒳×𝒳→ℝ. Then, the posterior distribution on f is a Gaussian process with mean mn:𝒳→ℝ and kernel kn:𝒳×𝒳→ℝ given by: mn(x)=m(x)+k(x,X)k(X,X)−1f(X)andkn(x,y)=k(x,y)−k(x,X)k(X,X)−1k(X,y). where (k(X,X))ij=k(xi,xj), (f(X))i=f(xi), (k(⋅,X))i=k(⋅,xi) and (k(X,⋅))i=k(xi,⋅). Furthermore, the posterior distribution on ν[f] is a univariate Gaussian distribution with mean 𝔼[ν[f]] and variance 𝕍[ν[f]] given by 𝔼[ν[f]]=ν[m]+ν[k(⋅,X)]k(X,X)−1f(X)and𝕍[ν[f]]=νν[k]−ν[k(⋅,X)]k(X,X)−1ν[k(X,⋅)]. The function ν[k(⋅,x)]=∫𝒳k(y,x)ν(dy) is the kernel mean embedding of k and νν[k]=∫𝒳k(x,y)ν(dx)ν(dy) denotes the integral of k with respect to both inputs. In particular, note that the posterior mean is a quadrature rule with weights wi=(ν[k(⋅,X)]k(X,X)−1)i. and the posterior variance provides a quantification of the user's uncertainty over the value of ν[f]. In more challenging integration problems, where the prior distribution cannot be relied upon as a meaningful representation of epistemic uncertainty, it is necessary to use the data f(x1),…,f(xn) to set the kernel hyperparameters using, for example, maximum likelihood estimation. The estimation of kernel hyperparameters introduces adaptivity into Bayesian quadrature.

Example

Consider estimation of the integral ν[f]=∫01f(x)dx≈1.79 of the function f(x)=(1+x2)sin⁡(5πx)+85 using a Bayesian quadrature rule based on a zero-mean Gaussian process prior with the Matérn covariance function of smoothness 3/2 and correlation length ρ=1/5. This covariance function is k(x,y)=(1+3|x−y|/ρ)exp⁡(−3|x−y|/ρ). It is straightforward (though tedious) to compute that ν[k(⋅,x)]=∫01k(y,x)dy=4ρ3−13exp⁡(3(x−1)ρ)(3+23ρ−3x)−13exp⁡(−3xρ)(3x+23ρ) νν[k]=∫01∫01k(x,y)dxdy=2ρ3[23−3ρ+exp⁡(−3ρ)(3+3ρ)]. Convergence of the Bayesian quadrature point estimate 𝔼[ν[f]] and concentration of the posterior mass, as quantified by 𝕍[ν[f]], around the true integral ν[f] as f is evaluated at more and more points is displayed in the accompanying animation.

Advantages and disadvantages Since Bayesian quadrature is an example of probabilistic numerics, it inherits certain advantages compared with traditional numerical integration methods:

It allows uncertainty to be quantified and propagated through all subsequent computations to explicitly model the impact of numerical error. It provides a principled way to incorporate prior knowledge by using a judicious choice of prior distributions for f, which may be more sophisticated compared to the standard Gaussian process just described. It permits more efficient use of information, e.g. jointly inferring multiple related quantities of interest or using active learning to reduce the required number of points. Despite these merits, Bayesian quadrature methods possess the following limitations:

Although the Bayesian paradigm allows a principled treatment of the quantification of uncertainty, posterior inference over ν[f] is not always tractable, thus requiring a second-level estimation. E.g. for Bayesian quadrature with Gaussian processes, the kernel mean embedding ν[k(⋅,x)] has no closed-form expression for a general kernel k and measure ν. The computational cost of Bayesian quadrature methods based on Gaussian processes is in general 𝒪(n3) due to the cost of inverting n×n matrices, which may defy their applications to large-scale problems.

Algorithmic design

Prior distributions The most commonly used prior for f is a Gaussian process prior. This is mainly due to the advantage provided by Gaussian conjugacy and the fact that Gaussian processes can encode a wide range of prior knowledge including smoothness, periodicity and sparsity through a careful choice of prior covariance. However, a number of other prior distributions have also been proposed. This includes multi-output Gaussian processes, which are particularly useful when tackling multiple related numerical integration tasks simultaneously or sequentially, and tree-based priors such as Bayesian additive regression trees, which are well suited for discontinuous f. Additionally, Dirichlet processes priors have also been proposed for the integration measure ν.

… excerpt ends here. Continue reading the full article.

Illustrations

Bayesian quadrature: Bayesian quadrature with a Gaussian process conditioned on n=0,3, and 8 evaluations of the integrand (shown in black). Shaded areas in the left column illustrate the marginal standard deviations. The right figure shows the prior (n=0) and posterior  (n=3,8) Gaussian distribution over the value of the integral, as well as the true solution.
Bayesian quadrature with a Gaussian process conditioned on n=0,3, and 8 evaluations of the integrand (shown in black). Shaded areas in the left column illustrate the marginal standard deviations. The right figure shows the prior (n=0) and posterior (n=3,8) Gaussian distribution over the value of the integral, as well as the true solution.
Bayesian quadrature: Illustration of Bayesian quadrature for estimating ν[f]=∫01f(x)dx where f(x)=(1+x2)sin⁡(5πx)+8/5. The posterior distribution (blue) concentrates on the true integral when more data (the red points) is obtained of the integrand f.
Illustration of Bayesian quadrature for estimating ν[f]=∫01f(x)dx where f(x)=(1+x2)sin⁡(5πx)+8/5. The posterior distribution (blue) concentrates on the true integral when more data (the red points) is obtained of the integrand f.

Worked examples

Example 1 — a first encounter with Bayesian quadrature

Start with the simplest possible case. Write down what Bayesian quadrature claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bayesian quadrature before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bayesian quadrature ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bayesian quadrature

In research
Bayesian quadrature appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bayesian quadrature in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bayesian quadrature is common in secondary-school and first-year university syllabi. It links to neighbouring topics Bayesian inference, Kernel methods for machine learning, Monte Carlo methods, so understanding it makes those chapters shorter.
In everyday life
Look for Bayesian quadrature outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bayesian quadrature” →

How to study Bayesian quadrature in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bayesian quadrature means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bayesian quadrature out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bayesian quadrature in simple terms?

Bayesian quadrature is a method for approximating intractable integration problems. It falls within the class of probabilistic numerical methods.

Why does Bayesian quadrature matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bayesian quadrature?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bayesian quadrature.

Tags

  • Bayesian inference
  • Kernel methods for machine learning
  • Monte Carlo methods
  • Numerical integration

Keep exploring