I'm approaching the topic of GP, and I have a question regarding how functions are sampled.

On my textbook is stated that to represent a distribution over a function (the prior):

we only need to be able to define a distribution over the function’s values at a finite, but arbitrary, set of points, say x1, . . . , xN .

Now, this confuses me, how do we compute the probability distribution between two points? For instance, if we know $P(X_1)$ and $P(X_2)$ how do we compute the distribution between these two points?

More tangibly, how do we sample an infinite number of points from $\mathcal{N}(f|\mu,K)$ and make this nice graph of GP Prior? (From Machine Learning a Probabilistic Approach)

enter image description here


To create those graphs, there wouldn't be a need (nor would it be feasible) to sample at an infinite number of points. Instead, you would sample a finite number of points with fine enough resolution, and interpolate between them to draw the graph. If you look closely at the plot, you will see that the curves are actually made up of straight line segments.

The mean function and kernel of the Gaussian process itself defines what distribution to sample from. For example, if we had a Gaussian process defined by $f\left(\mathbf{x}\right) \sim GP\left(m\left(\mathbf{x}\right), \kappa\left(\mathbf{x}, \mathbf{x}'\right)\right)$ (using the same notation as Murphy's Machine Learning book), and wanted to sample the process at points $\mathbf{x}_{1}$ and $\mathbf{x}_{2}$, then we would do so from the bivariate Gaussian distribution: $$\begin{bmatrix} f\left(\mathbf{x}_{1} \right) \\ f\left(\mathbf{x}_{2} \right) \end{bmatrix} \sim \mathcal{N}\left(\begin{bmatrix} m\left(\mathbf{x}_{1} \right) \\ m\left(\mathbf{x}_{2} \right) \end{bmatrix}, \begin{bmatrix}\kappa\left(\mathbf{x}_{1}, \mathbf{x}_{1}\right) & \kappa\left(\mathbf{x}_{1}, \mathbf{x}_{2}\right) \\ \kappa\left(\mathbf{x}_{2}, \mathbf{x}_{1}\right) & \kappa\left(\mathbf{x}_{2}, \mathbf{x}_{2}\right)\end{bmatrix}\right)$$ This can be readily extended, so that sampling any Gaussian process at a finite number of points just involves sampling from a multivariate Gaussian distribution.

  • 1
    $\begingroup$ So in order to make this graph, you need to sample from* a very high (yet finite) dimensional multivariate Gaussian $\endgroup$ – Tommaso Bendinelli Jan 11 at 19:24
  • 2
    $\begingroup$ Yep, that's correct. $\endgroup$ – rzch Jan 11 at 21:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.