Solution (source code)

= Solution

A <Dirichlet process mixture model> avoids fixing the number of occupied functions. Let $G_0=N_n(0,K)$ be the finite-dimensional <Gaussian process> law on the common input grid and specify
$$
G\sim\operatorname{DP}(\alpha,G_0),
\qquad
f_i\mid G\overset{\mathrm{iid}}\sim G,
\qquad
y_i\mid f_i\sim N_n(f_i,\sigma^2I_n).
$$
A draw from a <Dirichlet process> is almost surely discrete, so several $f_i$ coincide and thereby form clusters. The number of occupied clusters is random and can grow with the data.