📄 parzenwnd.cpp
字号:
// ParzenWnd.cpp: implementation of the CParzenWnd class.
//
//////////////////////////////////////////////////////////////////////
#include "ParzenWnd.h"
#include <cmath>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CParzenWnd::CParzenWnd(int nDim):CEstimate(nDim)
{
}
CParzenWnd::~CParzenWnd()
{
}
//基类中使用方窗作为缺省
double CParzenWnd::WndFunc(vector<double> u)
{
vector <double>::iterator vi;
double len = 0.0;
//首先判断维数是否正确
if (u.size() != m_nDim)
{
exit(0);
return -1;
}
//判断其和原点的距离, 利用 二范数
for (vi = u.begin(); vi != u.end(); vi++)
{
len += (*vi) * (*vi);
}
if (sqrt(len) <= 0.5)
return 1;
else
return 0;
}
double CParzenWnd::Probility(vector<double> x)
{
const double VN = 1.0;
double p = 0.0;
list <vector<double> >::iterator li;
//实现在x处的内插函数
for (li = m_listSample.begin(); li != m_listSample.end(); li++)
{
p += WndFunc(VecOperator(x , *li,1));
}
return p / m_listSample.size();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -