14 #ifndef MLPACK_CORE_KERNELS_GAUSSIAN_KERNEL_HPP
15 #define MLPACK_CORE_KERNELS_GAUSSIAN_KERNEL_HPP
50 gamma(-0.5 * pow(bandwidth, -2.0))
64 template<
typename VecTypeA,
typename VecTypeB>
65 double Evaluate(
const VecTypeA& a,
const VecTypeB& b)
const
81 return exp(gamma * std::pow(t, 2.0));
93 return 2 * t * gamma * exp(gamma * std::pow(t, 2.0));
105 return gamma * exp(gamma * t);
116 return pow(sqrt(2.0 *
M_PI) * bandwidth, (
double) dimension);
126 template<
typename VecTypeA,
typename VecTypeB>
130 2.0)) / (
Normalizer(a.n_rows) * pow(2.0, (
double) a.n_rows / 2.0));
141 this->bandwidth = bandwidth;
142 this->gamma = -0.5 * pow(bandwidth, -2.0);
146 double Gamma()
const {
return gamma; }
149 template<
typename Archive>
152 ar & BOOST_SERIALIZATION_NVP(bandwidth);
153 ar & BOOST_SERIALIZATION_NVP(gamma);
void serialize(Archive &ar, const unsigned int)
Serialize the kernel.
This is a template class that can provide information about various kernels.
double Gradient(const double t) const
Evaluation of the gradient of Gaussian kernel given the distance between two points.
double Gamma() const
Get the precalculated constant.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
GaussianKernel(const double bandwidth)
Construct the Gaussian kernel with a custom bandwidth.
double GradientForSquaredDistance(const double t) const
Evaluation of the gradient of Gaussian kernel given the squared distance between two points...
GaussianKernel()
Default constructor; sets bandwidth to 1.0.
double Bandwidth() const
Get the bandwidth.
double Evaluate(const double t) const
Evaluation of the Gaussian kernel given the distance between two points.
double ConvolutionIntegral(const VecTypeA &a, const VecTypeB &b)
Obtain a convolution integral of the Gaussian kernel.
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
The standard Gaussian kernel.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluation of the Gaussian kernel.
void Bandwidth(const double bandwidth)
Modify the bandwidth.
double Normalizer(const size_t dimension)
Obtain the normalization constant of the Gaussian kernel.
static const bool UsesSquaredDistance
If true, then the kernel include a squared distance, ||x - y||^2 .