# Gaussian Processes, basic question about how the prior is computed

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)

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.