📄 gaussiankernel.hpp
字号:
#ifndef INDII_ML_AUX_GAUSSIANKERNEL_HPP#define INDII_ML_AUX_GAUSSIANKERNEL_HPP#include "Kernel.hpp"namespace indii { namespace ml { namespace aux {/** * Gaussian kernel for density estimation. * * @author Lawrence Murray <lawrence@indii.org> * @version $Rev: 404 $ * @date $Date: 2008-03-05 14:52:55 +0000 (Wed, 05 Mar 2008) $ */class GaussianKernel : public Kernel {public: /** * Constructor. * * @param N \f$N\f$; dimensionality of the problem. * @param h \f$h\f$; the scaling parameter (bandwidth). * * Although the kernel itself is not intrinsically dependent on \f$N\f$ * and \f$h\f$, its normalisation is. Supplying these allows substantial * performance increases through precalculationa. */ GaussianKernel(const unsigned int N, const double h); virtual double operator()(const double x) const; /** * Sample from the kernel. * * @return A sample from the kernel. */ virtual double sample() const; private: /** * \f$h\f$; the scaling parameter (bandwidth). */ double h; /** * \f$(h\sqrt{2\pi})^{-1}\f$; the normalisation term. */ double ZI; /** * \f$(-2h^2)^{-1}\f$; the exponent term. */ double E;}; } }}#include <math.h>inline double indii::ml::aux::GaussianKernel::operator()(const double x) const { return ZI * exp(E * pow(x,2));}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -