SumKernel<T>
Models & Types · AiDotNet.Kernels
Implements a Sum kernel that combines multiple kernels by adding their outputs.
Implements: IKernelFunction<T>
For Beginners
The Sum kernel allows you to combine multiple kernels by adding their similarity scores together. This creates a more expressive model that can capture different types of patterns simultaneously.
In mathematical terms: k_sum(x, x’) = k1(x, x’) + k2(x, x’) + … + kn(x, x’)
How It Works
Why use Sum kernels?
- Multiple pattern types: Combine a smooth kernel (RBF) with a periodic kernel
to model data with both smooth trends and seasonal patterns.
- Additive structure: If your function can be decomposed into additive components,
each handled by a different kernel.
- Noise modeling: Add a WhiteNoise kernel to model observation noise.
Example combinations:
- RBF + WhiteNoise: Smooth function with measurement noise
- RBF + Periodic: Smooth trend with seasonal variation
- Linear + RBF: Linear trend with non-linear deviations
- RBF(short) + RBF(long): Capture both local and global patterns
Example
using AiDotNet.Kernels;
using AiDotNet.Tensors.LinearAlgebra;
var kernel = new SumKernel<double>();
var a = new Vector<double>(new[] { 1.0, 2.0, 3.0 });
var b = new Vector<double>(new[] { 1.5, 1.0, 2.5 });
double similarity = kernel.Calculate(a, b);
Console.WriteLine($"SumKernel: K(a, b) = {similarity:F4}");
Constructors
| Constructor | Summary |
|---|---|
SumKernel(IKernelFunction<T>[] kernels) |
Initializes a new Sum kernel from an array of kernels. |
Methods
| Method | Summary |
|---|---|
IKernelFunction<T>[] GetKernels() |
Gets the component kernels in this sum. |
T Calculate(Vector<T> x1, Vector<T> x2) |
Calculates the Sum kernel value between two vectors. |