remove epanechnikov_kernel

Signed-off-by: Omar Shrit <omar@shrit.me>
This commit is contained in:
Omar Shrit
2021-11-13 19:23:57 +00:00
parent 3e165bfc3e
commit 7558d383f7
@@ -14,67 +14,4 @@
using namespace mlpack;
using namespace mlpack::kernel;
/**
* Compute the normalizer of this Epanechnikov kernel for the given dimension.
*
* @param dimension Dimension to calculate the normalizer for.
*/
double EpanechnikovKernel::Normalizer(const size_t dimension)
{
return 2.0 * pow(bandwidth, (double) dimension) *
std::pow(M_PI, dimension / 2.0) /
(std::tgamma(dimension / 2.0 + 1.0) * (dimension + 2.0));
}
/**
* Evaluate the kernel not for two points but for a numerical value.
*/
double EpanechnikovKernel::Evaluate(const double distance) const
{
return std::max(0.0, 1 - std::pow(distance, 2.0) * inverseBandwidthSquared);
}
/**
* Evaluate gradient of the kernel not for two points
* but for a numerical value.
*/
double EpanechnikovKernel::Gradient(const double distance) const
{
if (std::abs(bandwidth) < std::abs(distance))
{
return 0;
}
else if (std::abs(bandwidth) > std::abs(distance))
{
return -2 * inverseBandwidthSquared * distance;
}
else
{
// The gradient doesn't exist.
return arma::datum::nan;
}
}
/**
* Evaluate gradient of the kernel not for two points
* but for a numerical value.
*/
double EpanechnikovKernel::GradientForSquaredDistance(const double
distanceSquared) const
{
double bandwidthSquared = bandwidth * bandwidth;
if (distanceSquared < bandwidthSquared)
{
return -1 * inverseBandwidthSquared;
}
else if (distanceSquared > bandwidthSquared &&
distanceSquared >= 0)
{
return 0;
}
else
{
// The gradient doesn't exist.
return arma::datum::nan;
}
}