mlpack  3.4.2
epanechnikov_kernel.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_KERNELS_EPANECHNIKOV_KERNEL_HPP
13 #define MLPACK_CORE_KERNELS_EPANECHNIKOV_KERNEL_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace kernel {
20 
31 {
32  public:
38  EpanechnikovKernel(const double bandwidth = 1.0) :
39  bandwidth(bandwidth),
40  inverseBandwidthSquared(1.0 / (bandwidth * bandwidth))
41  { }
42 
51  template<typename VecTypeA, typename VecTypeB>
52  double Evaluate(const VecTypeA& a, const VecTypeB& b) const;
53 
58  double Evaluate(const double distance) const;
59 
65  double Gradient(const double distance) const;
66 
72  double GradientForSquaredDistance(const double distanceSquared) const;
82  template<typename VecTypeA, typename VecTypeB>
83  double ConvolutionIntegral(const VecTypeA& a, const VecTypeB& b);
84 
90  double Normalizer(const size_t dimension);
91 
95  template<typename Archive>
96  void serialize(Archive& ar, const unsigned int version);
97 
98  private:
100  double bandwidth;
102  double inverseBandwidthSquared;
103 };
104 
106 template<>
108 {
109  public:
111  static const bool IsNormalized = true;
113  static const bool UsesSquaredDistance = true;
114 };
115 
116 } // namespace kernel
117 } // namespace mlpack
118 
119 // Include implementation.
120 #include "epanechnikov_kernel_impl.hpp"
121 
122 #endif
mlpack::kernel::KernelTraits
This is a template class that can provide information about various kernels.
Definition: kernel_traits.hpp:28
mlpack::kernel::KernelTraits::IsNormalized
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
Definition: kernel_traits.hpp:33
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::kernel::EpanechnikovKernel::serialize
void serialize(Archive &ar, const unsigned int version)
Serialize the kernel.
mlpack::kernel::EpanechnikovKernel::Evaluate
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the Epanechnikov kernel on the given two inputs.
mlpack::kernel::EpanechnikovKernel
The Epanechnikov kernel, defined as.
Definition: epanechnikov_kernel.hpp:31
mlpack::kernel::EpanechnikovKernel::ConvolutionIntegral
double ConvolutionIntegral(const VecTypeA &a, const VecTypeB &b)
Obtains the convolution integral [integral of K(||x-a||) K(||b-x||) dx] for the two vectors.
mlpack::kernel::EpanechnikovKernel::GradientForSquaredDistance
double GradientForSquaredDistance(const double distanceSquared) const
Evaluate the Gradient of Epanechnikov kernel given that the squared distance between the two input po...
mlpack::kernel::EpanechnikovKernel::Normalizer
double Normalizer(const size_t dimension)
Compute the normalizer of this Epanechnikov kernel for the given dimension.
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
mlpack::kernel::EpanechnikovKernel::Gradient
double Gradient(const double distance) const
Evaluate the Gradient of Epanechnikov kernel given that the distance between the two input points is ...
mlpack::kernel::EpanechnikovKernel::Evaluate
double Evaluate(const double distance) const
Evaluate the Epanechnikov kernel given that the distance between the two input points is known.
kernel_traits.hpp
mlpack::kernel::EpanechnikovKernel::EpanechnikovKernel
EpanechnikovKernel(const double bandwidth=1.0)
Instantiate the Epanechnikov kernel with the given bandwidth (default 1.0).
Definition: epanechnikov_kernel.hpp:38
mlpack::kernel::KernelTraits::UsesSquaredDistance
static const bool UsesSquaredDistance
If true, then the kernel include a squared distance, ||x - y||^2 .
Definition: kernel_traits.hpp:38