µGauss fits Gaussian process regression models to arbitrary scalar time series directly from symbolic expressions for the mean and covariance kernel. Users upload their own series and author their own kernel and mean formulas—with sample datasets included purely as editable starting points rather than built-in solver templates—and the exact marginal-likelihood engine compiles and maximizes those expressions immediately. The posterior Gaussian process then yields point forecasts, uncertainty intervals, additive component decompositions, and exact statistics of nonlinear functions of the forecast. Following Rasmussen and Williams [1] as the baseline reference for unproved results, this article develops the mathematical pipeline—from finite-dimensional conditioning and symbolic covariance algebra through profile trends, 1D transformed-forecast laws, and implicit-function parameter sensitivities—while marking where user-authored formulas extend beyond standard kernels. Interactive fits run in the µGauss workbench. For a guided walkthrough see Using µGauss, and for grammar and field behavior see the µGauss reference.
1. Gaussian processes
A Gaussian process is a collection $\{f(t) : t \in \mathbb{R}\}$ of real random variables whose every finite subset follows a joint normal distribution. Two functions fix the entire law: the mean function $m(t) = \mathbb{E}[f(t)]$ and the covariance function $k(s, t) = \operatorname{Cov}(f(s), f(t))$, written $f \sim \mathcal{GP}(m, k)$. Any covariance function must be symmetric and positive semi-definite. Consequently the matrix with entries $k(t_i, t_j)$ has no negative eigenvalue for any finite set of times $t_1, \dots, t_p$. Conversely, any mean function paired with a symmetric, positive semi-definite $k$ defines consistent marginal normal distributions and therefore a valid process.
Regression treats observations as noisy evaluations of a latent process $x \sim \mathcal{GP}(\mu, k_x)$ at times $t_1, \dots, t_n$,
$$ \begin{aligned} y_i &= x(t_i) + \varepsilon_i , \\ \varepsilon_i &\sim \mathcal{N}(0, \sigma_\varepsilon^2) , \end{aligned} $$where the observation errors $\varepsilon_i$ are mutually independent and independent of $x$. Sampling times need not be ordered or distinct. Marginally, the observation vector $y = (y_1, \dots, y_n)^\top$ is multivariate normal,
$$ \begin{aligned} y &\sim \mathcal{N}(\mu, K) , \\ K &= K_x + \sigma_\varepsilon^2 I , \end{aligned} $$with $\mu_i = \mu(t_i)$ and $(K_x)_{ij} = k_x(t_i, t_j)$. Equivalently, $y$ follows a Gaussian process with covariance $k = k_x + k_\varepsilon$, where $k_\varepsilon(s, t) = \sigma_\varepsilon^2\,\delta(s, t)$ evaluates to $\sigma_\varepsilon^2$ when pairing an observation with itself and vanishes across distinct observations. Because noise attaches to each observation rather than to the timestamp, repeated measurements at the same $t$ carry independent errors and average down as expected, whereas omitting the noise term treats measurements as exact, which can endanger the numerical stability of the fits.
This formulation assumes independent Gaussian errors across observations. Heavy tails or isolated outliers violate that assumption and show up directly in the leave-one-out residuals of section 7, as illustrated on Mauna Loa CO2. Where consecutive aggregated observations remain smooth, replacing independent white noise with a correlated kernel fits far better, as in the global methane Matérn fit.
2. Conditioning
Prediction reduces to conditional expectation for jointly normal vectors. Partitioning
$$ \begin{pmatrix} a \\ b \end{pmatrix} \sim \mathcal{N}(m, \Sigma) , \qquad m = \begin{pmatrix} \mu_a \\ \mu_b \end{pmatrix} , \qquad \Sigma = \begin{pmatrix} A & C \\ C^\top & B \end{pmatrix} , $$makes the conditional law of $a$ given $b$ normal with
$$ \begin{aligned} \mathbb{E}(a \mid b) &= \mu_a + C B^{-1}(b - \mu_b) , \\ \operatorname{Cov}(a \mid b) &= A - C B^{-1} C^\top . \end{aligned} $$Setting $a = x(t_\ast)$ at target times $t_\ast$ and $b = y$, write $K_\ast$ for the cross-covariance matrix with entries $k_x(t_{\ast i}, t_j)$ and $r = y - \mu$ for the prior residual. Conditioning yields a normal posterior for the latent process at $t_\ast$,
$$ \begin{aligned} m_\ast &= \mu(t_\ast) + K_\ast K^{-1} r , \\ V_\ast &= k_x(t_\ast, t_\ast) - K_\ast K^{-1} K_\ast^\top , \end{aligned} $$while predictive intervals for future observations add $\sigma_\varepsilon^2 I$ to $V_\ast$. This is the standard predictive distribution of Rasmussen and Williams, section 2.2, and the posterior remains a Gaussian process with mean $m_\ast(t)$ and covariance $k_x(s, t) - K_s K^{-1} K_t^\top$.
Two structural properties govern how forecasts behave. First, the posterior mean is linear in the data residuals, $m_\ast(t) = \mu(t) + \sum_i \alpha_i\,k_x(t, t_i)$ with $\alpha = K^{-1} r$, expanding the correction as kernel basis functions centered at the observations. Second, the posterior covariance depends solely on the observation timestamps, the kernel, and the noise variance—never on the observed values $y$ themselves. Forecast band width is fixed once the sampling grid and hyperparameters are known.
3. Covariance functions
Any valid covariance kernel must remain symmetric and positive semi-definite on arbitrary point sets. Three algebraic operations preserve that property: multiplying by a positive scalar $\sigma^2 k$ scales the latent process by $\sigma$, adding $k_1 + k_2$ sums independent processes, and multiplying $k_1 k_2$ remains positive semi-definite by the Schur product theorem, representing the pointwise product of independent centered processes. Any expression assembled from valid base families via sums, products, and positive scales is therefore guaranteed to define a Gaussian process. By contrast, µGauss accepts arbitrary symbolic expressions in $s$ and $t$ and cannot verify global positive semi-definiteness ahead of fitting. An invalid formula surfaces only when the covariance matrix at the sampled times fails factorization.
A kernel is stationary when it depends only on lag, $k(s, t) = \kappa(s - t)$. By Bochner’s theorem [2], a continuous $\kappa$ is positive semi-definite if and only if it is the Fourier transform of a finite non-negative spectral measure $\mu$,
$$ \kappa(\tau) = \int e^{2\pi i \omega \tau}\,\mathrm{d}\mu(\omega) . $$The squared exponential carries a Gaussian spectral density, whereas a periodic kernel concentrates mass on harmonics of the frequency $\frac{1}{p}$. Stationarity also dictates long-horizon behavior: as $t_\ast$ moves several correlation lengths past the observations, $K_\ast \to 0$, pulling $m_\ast(t_\ast) \to \mu(t_\ast)$ and $V_\ast(t_\ast) \to k_x(t_\ast, t_\ast)$. Forecasts from purely stationary kernels always revert to the prior mean and marginal variance.
The core kernel families appear in the table below at unit amplitude $\sigma = 1$. In general, a trailing amplitude parameter multiplies the kernel value by $\sigma^2$.
| Kernel | Expression at unit amplitude | Parameters | Mean-square sample paths |
|---|---|---|---|
| Squared exponential | $\exp\!\left(-\frac{(s-t)^2}{2\ell^2}\right)$ | length scale $\ell$ | infinitely differentiable |
| Matérn 3/2 | $\left(1 + \frac{\sqrt{3}\,\lvert s-t\rvert}{\ell}\right)\exp\!\left(-\frac{\sqrt{3}\,\lvert s-t\rvert}{\ell}\right)$ | $\ell$ | once differentiable |
| Rational quadratic | $\left(1 + \frac{(s-t)^2}{2\alpha\ell^2}\right)^{-\alpha}$ | $\ell$, shape $\alpha$ | infinitely differentiable |
| Periodic | $\exp\!\left(-\frac{2\sin^2\left(\frac{\pi\lvert s-t\rvert}{p}\right)}{\ell^2}\right)$ | period $p$, $\ell$ | infinitely differentiable, period $p$ |
| Linear | $(s-c)(t-c)$ | offset $c$ | straight lines |
Sample-path regularity tracks the Matérn order $\nu$: a Matérn process is $\lceil\nu\rceil - 1$ times mean-square differentiable, making order $\frac12$ continuous but rough, $\frac32$ and $\frac52$ once and twice differentiable, and the squared exponential the smooth limit $\nu \to \infty$. The rational quadratic arises as a scale mixture of squared exponentials over inverse-gamma length scales. The periodic kernel maps time onto the circle $u(t) = (\cos\frac{2\pi t}{p}, \sin\frac{2\pi t}{p})$ before applying a squared exponential, since $\lVert u(s) - u(t)\rVert^2 = 4\sin^2\frac{\pi(s-t)}{p}$ [3]. Unlike stationary kernels, the linear kernel corresponds to $f(t) = w\,(t - c)$ with $w \sim \mathcal{N}(0, 1)$, so adding a constant and linear kernel performs Bayesian linear regression with Gaussian priors on level and slope and extrapolates linearly past the data. The full kernel vocabulary also includes Matérn $\frac12$ and $\frac52$, cosine, polynomial, Brownian motion, Brownian bridge, Ornstein–Uhlenbeck, fractional Brownian motion, and integrated Brownian motion kernels.
Composing kernels with sums and products isolates distinct time-series structures. A seasonal cycle whose phase or amplitude evolves slowly combines a periodic kernel with a long squared exponential envelope, as in the Canadian lynx envelope study, while short-horizon irregularity enters as an additive Matérn component:
$$ \begin{aligned} k_x(s,t) ={}& \sigma_1^2\,k_{\mathrm{Per}}(s,t)\,k_{\mathrm{SE}}(s,t) \\ &+ \sigma_2^2\,k_{\mathrm{Mat}}(s,t) , \end{aligned} $$written symbolically as Per(p, lp, a) * RBF(l2) + Mat32(l, b). Likewise, multiplying any term by $h(s)\,h(t)$ lets variance vary over time, producing either a linear seasonal ramp on airline passengers, a growing seasonal amplitude on Arctic sea ice, or a tanh level changepoint on the Nile flow. In a product term, only the product of component variances is identifiable from data—demonstrated explicitly with two free product amplitudes on the Nile flow—so one factor carries an amplitude parameter while the remaining factors take unit scale. Every parameter also carries a structural role—amplitude, length scale, period, rate, shape, exponent, Hurst exponent, offset, or origin—which determines its positivity domain and data-scaled search bounds.
4. Marginal likelihood
Conditioning in section 2 treats kernel and mean parameters $\theta$ as fixed. In the model fit, $\theta$ is estimated from the marginal likelihood—the probability density of the observed vector $y$ after integrating out the latent path $x$. Because $y \sim \mathcal{N}(\mu, K)$, the log marginal likelihood is
$$ \begin{aligned} L(\theta) &= \log p(y \mid \theta) \\ &= -\tfrac12\,r^\top K^{-1} r - \tfrac12 \log\lvert K\rvert - \tfrac{n}{2}\log 2\pi , \end{aligned} $$with $r = y - \mu$ and $K$ evaluated at $\theta$. The quadratic form $-\frac12 r^\top K^{-1} r$ rewards data fit, while the log-determinant $-\frac12 \log\lvert K\rvert$ penalizes model complexity by measuring the volume of the prior over data space, as in Rasmussen and Williams, section 5.4.1. Maximizing $L(\theta)$—type II maximum likelihood, or empirical Bayes—balances both terms automatically without a separate regularization weight, after which section 2 conditions on the maximizer.
Standard matrix-calculus identities, $\partial_{\theta_i} \log\lvert K\rvert = \operatorname{tr}\!\left(K^{-1}\,\partial_{\theta_i} K\right)$ and $\partial_{\theta_i} K^{-1} = -K^{-1}(\partial_{\theta_i} K)K^{-1}$, yield exact gradients. Writing $\alpha = K^{-1} r$,
$$ \begin{aligned} W &= \alpha\alpha^\top - K^{-1} , \\ \frac{\partial L}{\partial \theta_i} &= \tfrac12 \operatorname{tr}\!\left(W\,\frac{\partial K}{\partial \theta_i}\right) , \end{aligned} $$plus $\alpha^\top\,\frac{\partial\mu}{\partial\theta_i}$ for any parameter entering a symbolic mean formula. Because µGauss differentiates kernel and mean expressions symbolically rather than taking finite differences, gradients remain exact up to floating-point rounding, letting quasi-Newton optimization converge quickly and enabling exact parameter sensitivities in section 8.
Evaluating $K^{-1}$ and $\log\lvert K\rvert$ through dense Cholesky factorization costs $\mathcal{O}(n^3)$ arithmetic operations and $\mathcal{O}(n^2)$ storage, while each parameter trace in the likelihood gradient adds $\mathcal{O}(n^2)$ work. Exact GP inference therefore remains practical up to a few thousand observations, with hosted demo caps listed under Demo Mode on the workbench page.
5. Mean function
The mean $\mu(t)$ is specified either as a polynomial trend $\mu = H\beta$, where the columns of $H$ hold $1, t, \dots, t^d$ at the observed times, or as a symbolic formula in $t$. Parameters inside a symbolic mean are optimized jointly with kernel parameters.
Polynomial trend coefficients $\beta$ are eliminated analytically instead of searched numerically. At fixed kernel parameters, $L$ is strictly concave quadratic in $\beta$ and attains its maximum at the generalized least-squares estimate,
$$ \hat\beta = \left(H^\top K^{-1} H\right)^{-1} H^\top K^{-1} y . $$Numerical optimization acts solely on the profile likelihood $L(\theta, \hat\beta(\theta))$. Because $\hat\beta$ satisfies $\partial_\beta L = 0$, the envelope theorem removes any $\frac{\partial\hat\beta}{\partial\theta_i}$ term from the profile gradient, leaving the formula of section 4 unchanged while still counting $\beta$’s parameters in the information criteria of section 6.
Two readings of the trend yield two predictive variance modes. Giving $\beta$ an independent Gaussian prior $\beta \sim \mathcal{N}(b, B)$ induces $y \sim \mathcal{N}(Hb, K + HBH^\top)$, folding the trend into the prior covariance—the exact Bayesian linear regression equivalence checked numerically on Lake Huron. Letting $B \to \infty$ for a diffuse prior gives the limiting posterior mean and variance of Rasmussen and Williams, section 2.7,
$$ \begin{aligned} m_\ast &= \mu_\ast + K_\ast K^{-1} r , \\ V_\ast &\mapsto V_\ast + R^\top A^{-1} R , \\ A &= H^\top K^{-1} H , \\ R &= H_\ast^\top - H^\top K^{-1} K_\ast^\top , \end{aligned} $$where $\mu_\ast = H_\ast\hat\beta$ and $H_\ast$ collects $1, t, \dots, t^d$ at $t_\ast$. In rigid mode, $\hat\beta$ is treated as fixed and $R^\top A^{-1} R$ is omitted, while in uncertain mode that variance correction is included. The correction stays negligible inside the observed span and grows steadily beyond it, reflecting slope uncertainty during extrapolation. Kernel and trend estimates themselves stay identical under both modes, as restricted maximum likelihood—subtracting $\frac12\log\lvert A\rvert$ from $L$—is not used.
Choosing the right trend degree outweighs the mode choice, as measured in the held-out forecast coverage benchmark. Averaged across 28 combinations of kernels and sample lengths on Mauna Loa $\mathrm{CO}_2$—each fitted on the first 80% and tested on the held-out 20%—a degree-1 trend misses the accelerating rise regardless of mode, whereas degree 2 recovers nominal 90% coverage:
| Trend specification | Held-out points inside 90% band |
|---|---|
| Line, rigid | 29% |
| Line, uncertain | 33% |
| Degree 2, rigid | 75% |
| Degree 2, uncertain | 89% |
Uncertain bands widen around a misspecified curve rather than rescuing it. Leave-one-out residuals on CO2 do not flag an incorrect trend degree because interior points interpolate between two neighbors, whereas BIC and held-out forecast coverage expose it immediately.
6. Estimation
Optimization operates in unconstrained or box-scaled coordinates determined by each parameter’s role—logarithmic for positive scales, unit-interval scaled for two-sided bounds, and linear otherwise—minimizing $-L(\theta)$ via L-BFGS-B [4] with exact symbolic gradients.
Because marginal likelihood surfaces are generally non-convex, a single optimizer trajectory can stall at a local peak—such as the non-periodic plateau mapped in the sunspot period profile or the flat noise-length-scale ridge in the profile likelihood over noise levels on the Nile. µGauss runs multi-start optimization from seeded random initializations across the search box alongside the user’s starting point and keeps the highest likelihood found. A fit is flagged fragile whenever fewer than half of successful restarts converge within tolerance of the best optimum, signaling competing modes that warrant additional restarts or tighter parameter ranges.
When an optimum lies strictly inside its box bounds and the negative Hessian $-H_L$ of $L$ is positive definite, inverse observed information $(-H_L)^{-1}$ yields asymptotic standard errors on the diagonal. At active bounds or flat likelihood ridges those errors are omitted, and in all cases they reflect local curvature around $\hat\theta$ rather than being propagated into section 7’s forecast bands, which remain conditional on the point estimate $\hat\theta$.
Competing models on the same dataset are ranked by information criteria,
$$ \begin{aligned} \mathrm{AIC} &= -2L + 2d , \\ \mathrm{BIC} &= -2L + d\log n , \end{aligned} $$where $d$ counts free hyperparameters plus polynomial trend coefficients [5][6]. With correlated time-series observations both rely on approximate asymptotic regularity and serve to compare models rather than test hypotheses formally—much as AIC and BIC rank competing multivariate families on fixed marginals in Sklar copula fitting.
7. Prediction and diagnostics
At every time $t_\ast$, the predictive distribution of the latent process is $\mathcal{N}(m_\ast, v_\ast)$ with $50\%$ and $90\%$ intervals $m_\ast \pm z\sqrt{v_\ast}$ at $z = 0.674$ and $z = 1.645$. Prediction bands for a future measurement $y_\ast$ replace $v_\ast$ with $v_\ast + \sigma_\varepsilon^2$.

When the covariance splits into additive terms $k_x = \sum_j k_j$, the latent process decomposes into independent prior components $x = \sum_j x_j$ whose individual posterior marginals follow from cross-covariances $K_{j\ast}$ built from $k_j$ alone:
$$ \begin{aligned} m_j &= K_{j\ast} K^{-1} r , \\ V_j &= k_j(t_\ast, t_\ast) - K_{j\ast} K^{-1} K_{j\ast}^\top . \end{aligned} $$Component means sum to $m_\ast - \mu_\ast$, while component variances do not sum to $v_\ast$ because posterior conditioning couples components across shared residuals.
Leave-one-out predictive densities for each observation $y_i$ given $y_{-i}$ follow analytically from the precision matrix $K^{-1}$ without refitting, matching Rasmussen and Williams, section 5.4.2:
$$ \begin{aligned} \mu_i^{\mathrm{loo}} &= y_i - \frac{[K^{-1} r]_i}{[K^{-1}]_{ii}} , \\ \sigma_i^{2,\mathrm{loo}} &= \frac{1}{[K^{-1}]_{ii}} . \end{aligned} $$Under a well-specified Gaussian model, standardized residuals $\frac{y_i - \mu_i^{\mathrm{loo}}}{\sigma_i^{\mathrm{loo}}}$ follow a standard normal distribution, surfacing outliers and heteroskedasticity immediately—though, as noted in section 5, missing a low-order trend stays largely hidden between adjacent observations.
8. Functions of the process and sensitivities
Because the posterior marginal at any fixed time $t$ is normal, $X \sim \mathcal{N}(m, s^2)$ with $m = m_\ast(t)$ and $s^2 = v_\ast(t)$, every pointwise statistic of a nonlinear transform $f(X)$ reduces to a one-dimensional integral against the standard normal density $\varphi$:
$$ \begin{aligned} \mathbb{P}\bigl(f(X) \le y\bigr) &= \int_{A_y} \varphi(z)\,\mathrm{d}z , \\ A_y &= \{z : f(m + sz) \le y\} . \end{aligned} $$Where $f$ is smooth and monotone, $A_y$ is a single interval bounded by $f^{-1}(y)$ and evaluates directly via the normal cumulative distribution function. Where $f$ has kinks, poles, or turning points, splitting the real line at critical points partitions $A_y$ into monotonic intervals. Quantiles solve $\mathbb{P}(f(X) \le y) = q$—collapsing to $f(q_X)$ when $f$ is monotone—and moments integrate against $\varphi$ over each smooth piece using adaptive Gauss–Legendre quadrature, flagging poles or undefined regions when integrals diverge.
Fitting the yearly Nile flow at Aswan from 1871 to 1970 in units of $10^8\,\mathrm{m}^3$ with $\sigma^2 k_{\mathrm{SE}} + \sigma_\varepsilon^2\delta$ and constant mean yields length scale $l = \ell = 2.59$ years, amplitude $a = \sigma = 119$, and noise $n = \sigma_\varepsilon = 116$, with log likelihood $-638.3$ and BIC $1295$. Evaluating the excess over threshold $900$, $R = \max(x - 900, 0)$, five years past the series highlights Jensen’s inequality clearly:
| Forecast statistic at 1975 | Value |
|---|---|
| Mean of $x$ | 907 |
| Mean of $R$ | 52.2 |
| $R$ evaluated at the mean of $x$ | 7.0 |
| 95% quantile of $x$ | 1107 |
| 95% quantile of $R$ | 207.4 |
Convexity of $\max(\cdot - 900, 0)$ lifts $\mathbb{E}[R]$ to $52.2$ against $R(\mathbb{E}[x]) = 7.0$, whereas monotonicity preserves the 95% quantile $1107 - 900 = 207.4$, as verified across four Nile thresholds against exact normal formulas to floating-point rounding.

Interval averages and integrals $\int_a^b w(t)\,x(t)\,\mathrm{d}t$ are linear functionals of a mean-square integrable Gaussian process and remain jointly normal. Discretized via quadrature weights $w$ on a grid $x_\ast$, the functional has posterior mean $w^\top m_\ast$ and variance $w^\top V_\ast w$ using the full grid covariance $V_\ast$—giving mean $907.1$ and standard deviation $71.2$ for the 1971–1990 Nile average—and derived nonlinear statistics of that scalar normal follow the same 1D integration.
Every reported statistic $S$ also carries exact parameter sensitivities. Differentiating through $K$, $K_\ast$, and $\mu$ yields partial derivatives $\frac{\partial S}{\partial\theta_i}$ with respect to both free and fixed parameters. When a fixed parameter $\theta_p$ varies, free parameters $\theta_f$ adjust to maintain the stationarity condition $\nabla_{\theta_f} L = 0$, so by the implicit function theorem
$$ \frac{\mathrm{d}\theta_f}{\mathrm{d}\theta_p} = -\,H_{ff}^{-1} H_{fp} , $$producing total sensitivities $\partial_p S + \sum_f \partial_f S\,\frac{\mathrm{d}\theta_f}{\mathrm{d}\theta_p}$. Sensitivities are reported as changes per one per cent increase in each parameter, $\frac{p}{100}\frac{\partial S}{\partial p}$:
| 1% sensitivity on Nile forecast | $l$ | $a$ | $n$ |
|---|---|---|---|
| Mean of $x$ in 1975 | $-0.56$ | $-0.059$ | $0.059$ |
| 95% quantile of $x$ in 1975 | $-0.64$ | $1.91$ | $0.095$ |
| Mean of $R$ in 1975 | $-0.31$ | $0.45$ | $0.040$ |
| Standard deviation of 1971–1990 average | $0.28$ | $0.68$ | $0.029$ |
Amplitude $a$ governs tail quantiles and interval spread while length scale $l$ shifts the extrapolation mean most strongly, leaving observation noise $n$ with minimal leverage five years out. Across horizons, those numbers also obey exact Euler homogeneity identities detailed across Nile forecast horizons, complementing the pathwise automatic differentiation used for parametric SDEs in Compiling parametric SDEs into fast Monte Carlo simulations.
Ready to try µGauss?
Upload your own time series and fit a custom symbolic kernel and mean, or start from an editable example.