GAUSSIAN PROCESS REGRESSION · KRIGING · CURVE FITTING WITH UNCERTAINTY · RUNS IN YOUR BROWSER · NOTHING UPLOADED

Fit a curve through my data, with an honest band around it

Paste two columns: a date or an x value, and a measurement. Gaussian process regression (Rasmussen & Williams 2006) fits a smooth curve that bends only as much as the data justify, with a 95% band that is narrow where you have points and widens where you do not. It tells you in your own units how quickly the curve changes, whether it repeats and how often, and how noisy the readings are; it tries seven kernels and keeps the one the evidence favours; and it checks the band by predicting each point from all the others.

Nothing you enter leaves this browser tab. Statistical output from data you supply, not advice. Not legal, tax, or financial advice.

Your data

Rows with a missing x or y are skipped. Dates are read as decimal years, so lengths and periods come out in years.

Method and citation

A Gaussian process treats the unknown curve as random, with the covariance between its values at two x values set by a kernel of their distance r. Given your points, the posterior mean and variance at any x follow in closed form (Rasmussen & Williams 2006, Algorithm 2.1): with K the kernel matrix plus noise and L its Cholesky factor, α = K⁻¹y, the mean is k*ᵀα and the variance k(x*,x*) − vᵀv, v = L⁻¹k*.

The kernel's settings (signal size, length scale, period, noise) are chosen by maximising the log marginal likelihood −yᵀK⁻¹y/2 − log|K|/2 − (n/2) log 2π with its exact gradient (eq. 5.9), using an L-BFGS optimiser (Liu & Nocedal 1989) in log space within bounds, from the default start plus seeded random restarts. y is centred and scaled first, as scikit-learn's normalize_y does. With the linear mean, the kernels are fitted to what a least-squares line leaves, and predictions use a straight line with a vague prior (section 2.7, eqs. 2.41–2.42), so the line's own uncertainty widens the band far from the data. The leave-one-out check uses the closed form of eqs. 5.10–5.12 (treating the line as known). The periodic kernel is MacKay's (1998) exp(−2 sin²(πr/p)/l²).

Verified by tests in the source against scikit-learn 1.9.1's GaussianProcessRegressor, on this page's example, for all seven kernels: the log marginal likelihood, its gradient, and the predictive mean and standard deviation agree to within 1e-9; from the same starting values, the fitted optimum matches or beats scikit-learn's in six kernels and, for the periodic kernel alone, stops at a different local optimum (both are reported in the source).

BibTeX

@book{rasmussen2006gaussian,
  author    = {Rasmussen, Carl Edward and Williams, Christopher K. I.},
  title     = {Gaussian Processes for Machine Learning},
  publisher = {MIT Press}, address = {Cambridge, MA}, year = {2006},
  isbn      = {026218253X}, url = {https://gaussianprocess.org/gpml/}
}
@article{liu1989limited,
  author  = {Liu, Dong C. and Nocedal, Jorge},
  title   = {On the limited memory {BFGS} method for large scale optimization},
  journal = {Mathematical Programming},
  volume  = {45}, pages = {503--528}, year = {1989},
  doi     = {10.1007/BF01589116}
}
@incollection{mackay1998introduction,
  author    = {MacKay, David J. C.},
  title     = {Introduction to {G}aussian processes},
  booktitle = {Neural Networks and Machine Learning},
  editor    = {Bishop, Christopher M.},
  series    = {NATO ASI Series F}, volume = {168},
  publisher = {Springer}, pages = {133--165}, year = {1998}
}

Limits

Questions

What does Gaussian process regression give me that a trend line does not?

A curve that bends as much as the data say it should, and a band around it that is narrow where you have data and widens where you do not. It also tells you, in your own units, over what distance the curve changes (the length scale), whether it repeats and how often (the period), and how much the readings scatter around it (the noise).

How are the settings of the curve chosen?

By maximising the log marginal likelihood: the probability of your data under the model, averaged over every curve the kernel allows. It rewards fitting the points and penalises needless flexibility at the same time, so a very wiggly curve that threads every point loses to a smoother one unless the data really demand it. The optimiser starts from several points, because the surface can have more than one peak.

What is a kernel and which one should I pick?

The kernel says how alike two points are given how far apart they are, which fixes what kind of curve is plausible: very smooth (RBF), rougher (Matern), a mix of scales (rational quadratic), repeating (periodic) or repeating with drift (quasi-periodic). On auto the tool fits all seven and keeps the one with the highest evidence; the table shows how far behind each other kernel is. A difference of a few log units is small; tens of units is decisive.

What does the leave-one-out check tell me?

Each point is predicted from all the others, and the tool counts how many fall inside their 95% interval. About 95% means the band is honest inside the range of your data. Far less means the band is too narrow; far more means it is too wide. It is computed exactly from one fit, not by refitting n times.

Can I trust the forecast past my last point?

Less than the band suggests. On this page's example, a fit on January 2010 to September 2023 forecast the next 36 months with an average miss of 1.08 ppm, about the same as simply repeating last year's month plus last year's rise (1.07 ppm), and only 42% of the 36 months fell inside the 95% band, because CO2 rose faster than the straight-line trend. Treat a GP forecast as a smooth continuation of the past, not a model of what drives the series.

Is my data uploaded anywhere?

No. The file is read and fitted by JavaScript in this browser tab. There are no accounts, cookies or analytics vendors.

Example data: monthly mean CO2 at Mauna Loa Observatory, Hawaii, January 2010 to September 2026, from the NOAA Global Monitoring Laboratory (gml.noaa.gov/ccgg/trends), retrieved 2026-11-13; data courtesy of NOAA GML. December 2022 to early July 2023 were measured on Maunakea after the Mauna Loa eruption.