GibbsKernel<T>

Models & Types · AiDotNet.Kernels

Implements the Gibbs kernel with input-dependent length scales for non-stationary covariance.

Implements: IKernelFunction<T>

For Beginners

The Gibbs kernel is a non-stationary kernel where the length scale can vary depending on where you are in input space. This allows modeling functions that are smooth in some regions and vary rapidly in others.

In mathematical terms: k(x, x’) = √(2×l(x)×l(x’) / (l(x)² + l(x’)²)) × exp(-r² / (l(x)² + l(x’)²))

Where:

  • l(x) is the length scale function evaluated at x
  • r = |x - x’| is the Euclidean distance

Unlike stationary kernels (like RBF) where the same length scale applies everywhere, the Gibbs kernel allows:

  • Tight length scales where you want to capture fine details
  • Long length scales where the function is smooth

How It Works

Applications:

  • Functions that transition between smooth and rough regions
  • Spatially varying correlation structures
  • Time series where dynamics change over time
  • Heteroscedastic (non-constant variance) modeling

Example: Stock prices might be smooth during normal trading but vary rapidly during market opens, news events, or high volatility periods.

Constructors

Constructor Summary
GibbsKernel(Func<Vector<T>, T> lengthScaleFunction, double variance) Initializes a new Gibbs kernel with a custom length scale function.

Properties

Property Summary
double Variance { get; } Gets the signal variance.

Methods

Method Summary
GibbsKernel<T> WithInterpolatedLengthScale(double[] lengthScaleValues, double gridMin, double gridMax, double variance) Creates a Gibbs kernel with length scale learned from data.
GibbsKernel<T> WithLinearLengthScale(double baseScale, double slope, double variance) Creates a Gibbs kernel with a linear length scale function.
GibbsKernel<T> WithSinusoidalLengthScale(double baseScale, double amplitude, double frequency, double variance) Creates a Gibbs kernel with a sinusoidal length scale function.
GibbsKernel<T> WithStepLengthScale(double scale1, double scale2, double threshold, double transitionWidth, double variance) Creates a Gibbs kernel with a step function length scale.
T Calculate(Vector<T> x1, Vector<T> x2) Calculates the Gibbs kernel value between two vectors.
T GetLengthScale(Vector<T> x) Gets the length scale at a given point.