12 #ifndef MLPACK_CORE_KERNELS_EPANECHNIKOV_KERNEL_IMPL_HPP 13 #define MLPACK_CORE_KERNELS_EPANECHNIKOV_KERNEL_IMPL_HPP 24 template<
typename VecTypeA,
typename VecTypeB>
29 * inverseBandwidthSquared);
43 template<
typename VecTypeA,
typename VecTypeB>
48 if (distance >= 2.0 * bandwidth)
51 double volumeSquared = std::pow(
Normalizer(a.n_rows), 2.0);
56 return 1.0 / volumeSquared *
57 (16.0 / 15.0 * bandwidth - 4.0 * distance * distance /
58 (3.0 * bandwidth) + 2.0 * distance * distance * distance /
59 (3.0 * bandwidth * bandwidth) -
60 std::pow(distance, 5.0) / (30.0 * std::pow(bandwidth, 4.0)));
62 return 1.0 / volumeSquared *
63 ((2.0 / 3.0 * bandwidth * bandwidth - distance * distance) *
64 asin(sqrt(1.0 - std::pow(distance / (2.0 * bandwidth), 2.0))) +
65 sqrt(4.0 * bandwidth * bandwidth - distance * distance) *
66 (distance / 6.0 + 2.0 / 9.0 * distance *
67 std::pow(distance / bandwidth, 2.0) - distance / 72.0 *
68 std::pow(distance / bandwidth, 4.0)));
70 Log::Fatal <<
"EpanechnikovKernel::ConvolutionIntegral(): dimension " 71 << a.n_rows <<
" not supported.";
77 template<
typename Archive>
81 ar(CEREAL_NVP(bandwidth));
82 ar(CEREAL_NVP(inverseBandwidthSquared));
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition: log.hpp:90
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void serialize(Archive &ar, const uint32_t version)
Serialize the kernel.
Definition: epanechnikov_kernel_impl.hpp:78
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...
Definition: epanechnikov_kernel_impl.hpp:44
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
Definition: lmetric_impl.hpp:24
double Normalizer(const size_t dimension)
Compute the normalizer of this Epanechnikov kernel for the given dimension.
Definition: epanechnikov_kernel.cpp:22
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the Epanechnikov kernel on the given two inputs.
Definition: epanechnikov_kernel_impl.hpp:25