TL;DR
A Gaussian process model needs a kernel, a function that says how strongly two inputs should agree. The spectral mixture kernel is a kernel built from cosines multiplied by Gaussian envelopes, and its parameters are chosen so that the kernel's Fourier view matches a few frequency bumps. A model with this kernel can find repeating patterns in data and extend them past the last observation.
Builds on: Gaussian Process Regression, Kernel Function, Stationary Process, Fourier Transform · Leads to: Power Spectral Density (the same Fourier view, from the signal side)
Where it's used
Forecasting demand with cycles. A utility records electricity use every hour. The load has a daily cycle, a weekly cycle, and a slow drift that is not periodic. A team fitting a Gaussian process with a spectral mixture kernel can let the data choose the daily and weekly periods, then forecast the next several days with error bars that widen as the forecast moves away from the data.
Filling gaps in sensor records. A weather station goes offline for a day. A model that knows the record repeats every 24 hours can fill the gap from the same hours on other days, and it reports how uncertain the filled values are. A plain smooth kernel would simply fade toward the average in the gap.
Searching for periodic signals. An astronomer watching the brightness of a star sees dips that might repeat. The spectral mixture kernel has a frequency parameter for each component, so the fitted frequencies show which periods the data support. The model is a tool for finding candidate periods, which then need checking with other evidence.
How it works
Take the simplest case: one component, with weight 1, frequency cycles per unit time, and spectral variance . The kernel depends only on the time gap τ between two inputs. We want its values at τ = 0, 1 and 2.
- Write the component. The kernel is the weight times a Gaussian envelope times a cosine: . Here the cosine uses frequency 1/6, so . Check: the parameters were chosen so that , which gives the envelope .
- Evaluate at τ = 0. The envelope is and the cosine is , so . Check: a point always agrees with itself fully, and this is the prior variance.
- Evaluate at τ = 1. The envelope is and the cosine is . So . Check: the value is positive, and it is smaller than .
- Evaluate at τ = 2. The envelope is and the cosine is . So . Check: the sign has flipped, so inputs two units apart are negatively related. That is the cosine at work.
- Read the shape. The kernel starts at 1, falls, and turns negative, while the envelope shrinks it toward zero for large gaps. A single component is a wave whose height fades with distance.
The figure shows the same single-component kernel over a wider range of gaps.
- one component
- envelope
The math
Definition
A spectral mixture kernel with components is
where is the gap between two inputs, is the weight of component , is its frequency (the centre of the spectral bump), and is its spectral variance. The kernel is stationary: it depends only on , as required by stationarity.
Step 1 in symbols: the envelope and the wave
Each term is a product of two pieces. The Gaussian envelope decays with the gap, and the cosine oscillates with period . The length scale of the envelope is , because . Check: this is the same envelope as a squared-exponential kernel with length scale .
Step 2 in symbols: the spectral density
The Fourier view of a stationary kernel is its spectral density , linked to the kernel by , the form the Wiener-Khinchin relation takes for a stationary process. For the spectral mixture kernel,
where is a normal density in with mean and variance . Each component is a pair of Gaussian bumps, one at and one at , which is why the kernel is symmetric in .
Step 3 in symbols: why the two views agree
The characteristic function of a normal variable with mean and variance is . Put and , and you get
Add the mirror bump at , which gives , and the two terms combine as . The envelope comes out unchanged. So the kernel and its spectral density are a Fourier pair, as the formula in step 2 claims.
Step 4 in symbols: the prior variance and validity
Setting gives . This is the prior variance of every function value. Validity follows from step 2: because the weights are nonnegative and each spectral bump is a density, , and a stationary kernel with a nonnegative spectral density is positive semidefinite. That is what lets it stand in for a covariance function, as described in Kernel Function.
Step 5 in symbols: the Gaussian process prediction
With the kernel built, the model is an ordinary Gaussian Process Regression. For training inputs with values , noise variance , and test input , the predictive mean is , and the predictive variance is , where holds and holds . The kernel's periodic part makes the mean repeat, and the envelope makes the variance grow with the distance from the data.
Worked examples
- Kernel: , with weight 1.
- At : .
- At : .
- At : .
- Interpretation: points one unit apart agree moderately, and points two units apart disagree a little. The period of the wave is 6, so the pattern repeats only after 6 units, and the envelope keeps the repeat weak.
Take two components with the same envelope . Component 1 has weight 1 and frequency 1/6. Component 2 has weight 0.5 and frequency 1 (period 1). The kernel is
- At : the bracket is and the envelope is 1, so . Check: this equals , the prior variance from step 4.
- At : the envelope is . The bracket is . So .
- At : the envelope is . The bracket is . So .
- Interpretation: component 2 repeats at every whole unit, and component 1 cancels it at two units. Two inputs two units apart are uncorrelated here, while one unit apart they are moderately correlated: .
An hourly temperature sensor shows a daily cycle, a weekly pattern, and no long-term trend. The fitted model has two components. Component 1 has weight 1, frequency 1/24 cycles per hour, and spectral variance . Component 2 has weight 0.2, frequency 1/168 cycles per hour, and spectral variance . We evaluate the covariance between a reading now and one 24 hours earlier.
- The envelope of component 1 at : , so the envelope is .
- Its cosine at : . Its contribution is .
- The envelope of component 2 at : , so the envelope is .
- Its cosine at : . Its contribution is .
- Total: . The prior variance is , so the correlation at a 24-hour gap is .
- Interpretation: a reading now is moderately related to the reading at the same hour yesterday. The daily component carries most of the relation, and the weekly one adds a little.
Try it: using the same two components, what is , the covariance one week apart? Answer: component 1 gives , so its envelope is essentially zero. Component 2 gives , so its envelope is , and its cosine is . Then , which is close to zero. The model says that a week later the readings are unrelated, because these parameters let the weekly wave fade within a few days.
Common mistakes and tradeoffs
It is tempting to think that a cosine kernel makes a model predict a perfect repeat forever. In fact the Gaussian envelope always shrinks the repeat with distance, and the length scale sets how fast. A large spectral variance gives a short length scale, and the pattern is forgotten quickly. Extrapolation far beyond the data relies on small spectral variances, which the data must support.
It is tempting to think that more components always help. In fact each component adds frequency, weight and variance parameters, and the marginal likelihood used to fit them can have many local optima. With few data points, extra components fit noise and extrapolate badly. Start with one or two components, and add more only if the fit and the held-out data both improve.
It is tempting to think the frequencies are periods you can read off directly. In fact a sharp is only as good as the data behind it. Short records give broad or unreliable frequency estimates, and the kernel can place a frequency at an alias of the true one when the sampling is coarse.
Use this kernel when the signal is smooth, stationary, and has one or more repeating patterns of unknown period. Do not use it when the series has a clear trend, since a trend needs its own term or a non-stationary kernel, or when the data are too few to pin down the frequencies. Simpler alternatives are the squared-exponential kernel, which assumes smoothness only, and a single periodic kernel with a fixed period when the period is known in advance.
History
Gaussian process models were long used in geostatistics and in machine learning, with kernels chosen by hand for smoothness. The standard references, such as the 2006 book by Rasmussen and Williams, showed how to fit kernel hyperparameters by maximising the marginal likelihood, but the kernels in common use were stationary and smooth without a built-in notion of repeating structure. In 2013 Andrew Wilson and Ryan Adams proposed the spectral mixture kernel in a paper at the International Conference on Machine Learning. Their idea was to write the kernel through its spectral density, as a mixture of Gaussian bumps, so that the data could reveal periodic structure and the model could extrapolate it. The idea caught on because it turned an opaque kernel choice into a few interpretable frequencies and widths.
Recap
- A stationary kernel is equivalent to a spectral density: the Fourier transform of one is the other.
- The spectral mixture kernel makes that density a sum of Gaussian bumps at chosen frequencies, which gives a sum of Gaussian-enveloped cosines in the time domain.
- Each component has a frequency for the repeat, a spectral variance that sets the length scale of the envelope, and a weight that sets its share of the prior variance.
- Plugged into a Gaussian process, the kernel gives predictions that repeat where the data repeat and widen their error bars away from the data.
Read next: Power Spectral Density, for the signal-side view of the same spectrum, and Marginal Likelihood, which is how the frequencies and widths are fitted.