CircularKernel<T>
Models & Types · AiDotNet.Kernels
Implements the Circular kernel function for measuring similarity between data points.
Implements: IKernelFunction<T>
For Beginners
A kernel function is a mathematical tool that measures how similar two data points are. The Circular kernel is special because it has a clear “cutoff point” - if two data points are too far apart (farther than sigma), they’re considered completely different (similarity = 0).
How It Works
The Circular kernel is a compact (finite support) kernel based on the circular function from statistics. It produces non-zero values only for points within a certain distance of each other, defined by the sigma parameter.
Think of the Circular kernel like a neighborhood with a strict boundary. Points inside the neighborhood have varying degrees of similarity based on how close they are to each other. But once you step outside the neighborhood boundary (defined by sigma), there’s no similarity at all.
This property makes the Circular kernel useful for problems where you want to focus only on local patterns and completely ignore distant relationships.
Example
using AiDotNet.Kernels;
using AiDotNet.Tensors.LinearAlgebra;
var kernel = new CircularKernel<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($"CircularKernel: K(a, b) = {similarity:F4}");
Constructors
| Constructor | Summary |
|---|---|
CircularKernel(T sigma) |
Initializes a new instance of the Circular kernel with an optional scaling parameter. |
Methods
| Method | Summary |
|---|---|
T Calculate(Vector<T> x1, Vector<T> x2) |
Calculates the Circular kernel value between two vectors. |