GaussianKernel Class |
Namespace: Accord.Statistics.Distributions.DensityKernels
[SerializableAttribute] public class GaussianKernel : IRadiallySymmetricKernel, IDensityKernel
The GaussianKernel type exposes the following members.
Name | Description | |
---|---|---|
GaussianKernel(Double) |
Initializes a new instance of the GaussianKernel class.
| |
GaussianKernel(Int32) |
Initializes a new instance of the GaussianKernel class.
|
Name | Description | |
---|---|---|
Derivative |
Computes the derivative of the kernel profile function.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Function |
Computes the kernel density function.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Profile |
Computes the kernel profile function.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
This class provides a Gaussian density kernel (not to be confused with a Gaussian kernel function) to be used in density estimation models (i.e. EmpiricalDistribution) and clustering algorithms (i.e. MeanShift.
References:
The following example shows how to fit a MultivariateEmpiricalDistribution using Gaussian kernels:
// Suppose we have the following data, and we would // like to estimate a distribution from this data double[][] samples = { new double[] { 0, 1 }, new double[] { 1, 2 }, new double[] { 5, 1 }, new double[] { 7, 1 }, new double[] { 6, 1 }, new double[] { 5, 7 }, new double[] { 2, 1 }, }; // Start by specifying a density kernel IDensityKernel kernel = new GaussianKernel(dimension: 2); // The density kernel gives a window function centered in a particular sample. // By creating one of those windows for each sample, we can achieve an empirical // multivariate distribution function. An output example for a single Gaussian // kernel would be: double z = kernel.Function(new double[] { 0, 1 }); // should be 0.096532352630053914 // Create a multivariate Empirical distribution from the samples var dist = new MultivariateEmpiricalDistribution(kernel, samples); // Common measures double[] mean = dist.Mean; // { 3.71, 2.00 } double[] median = dist.Median; // { 3.71, 2.00 } double[] var = dist.Variance; // { 7.23, 5.00 } (diagonal from cov) double[,] cov = dist.Covariance; // { { 7.23, 0.83 }, { 0.83, 5.00 } } // Probability mass functions double pdf1 = dist.ProbabilityDensityFunction(new double[] { 2, 1 }); // 0.017657515909330332 double pdf2 = dist.ProbabilityDensityFunction(new double[] { 4, 2 }); // 0.011581172997320841 double pdf3 = dist.ProbabilityDensityFunction(new double[] { 5, 7 }); // 0.0072297668067630525 double lpdf = dist.LogProbabilityDensityFunction(new double[] { 5, 7 }); // -4.929548496891365