HellingerKernel<T>
Models & Types · AiDotNet.Kernels
Implements the Hellinger kernel for measuring similarity between probability distributions.
Implements: IKernelFunction<T>
For Beginners
A kernel function is a mathematical tool that measures how similar two data points are. The Hellinger kernel is specifically designed for comparing data that represents probabilities or frequencies (like how often words appear in documents, or the distribution of pixel intensities in images).
How It Works
The Hellinger kernel is based on the Hellinger distance, which is a metric used to quantify the similarity between two probability distributions. This kernel is particularly useful when working with data that represents distributions, such as histograms, word frequencies, or any normalized non-negative data.
Think of this kernel as a “distribution comparator” that works well when your data points represent how things are distributed or how frequently they occur. It’s particularly good at handling sparse data (where many values are zero) and is less sensitive to outliers than some other kernels.
This kernel works best when your data contains non-negative values that sum to 1 (or can be normalized to sum to 1), such as probability distributions, normalized histograms, or frequency counts.
Note: For proper use of the Hellinger kernel, input vectors should contain non-negative values and ideally should be normalized (sum to 1). If your data doesn’t meet these criteria, you might need to preprocess it before using this kernel.
Example
using AiDotNet.Kernels;
using AiDotNet.Tensors.LinearAlgebra;
var kernel = new HellingerKernel<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($"HellingerKernel: K(a, b) = {similarity:F4}");
Constructors
| Constructor | Summary |
|---|---|
HellingerKernel() |
Initializes a new instance of the Hellinger kernel. |
Methods
| Method | Summary |
|---|---|
T Calculate(Vector<T> x1, Vector<T> x2) |
Calculates the Hellinger kernel value between two vectors. |