Click or drag to resize
Accord.NET (logo)

GaussianKernel Class

Gaussian density kernel.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.Distributions.DensityKernelsGaussianKernel

Namespace:  Accord.Statistics.Distributions.DensityKernels
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class GaussianKernel : IRadiallySymmetricKernel, 
	IDensityKernel
Request Example View Source

The GaussianKernel type exposes the following members.

Constructors
  NameDescription
Public methodGaussianKernel(Double)
Initializes a new instance of the GaussianKernel class.
Public methodGaussianKernel(Int32)
Initializes a new instance of the GaussianKernel class.
Top
Properties
  NameDescription
Public propertyConstant
Gets or sets the kernel's normalization constant.
Top
Methods
  NameDescription
Public methodDerivative
Computes the derivative of the kernel profile function.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFunction
Computes the kernel density function.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProfile
Computes the kernel profile function.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(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.)
Public Extension MethodToTOverloaded.
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.)
Top
Remarks

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:

  • Comaniciu, Dorin, and Peter Meer. "Mean shift: A robust approach toward feature space analysis." Pattern Analysis and Machine Intelligence, IEEE Transactions on 24.5 (2002): 603-619. Available at: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1000236
  • Dan Styer, Oberlin College Department of Physics and Astronomy; Volume of a d-dimensional sphere. Last updated 30 August 2007. Available at: http://www.oberlin.edu/physics/dstyer/StatMech/VolumeDSphere.pdf
  • David W. Scott, Multivariate Density Estimation: Theory, Practice, and Visualization, Wiley, Aug 31, 1992

Examples

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
See Also