⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 estimate.cpp

📁 Parzen 窗 和 K近邻法进行概率密度估计 还带一个示波器控件.
💻 CPP
字号:
// Estimate.cpp: implementation of the CEstimate class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "Estimate.h"

#include <cmath>
#include <assert.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CEstimate::CEstimate(int nDim)
{
	assert(nDim > 0);
	m_nDim = nDim;
}

CEstimate::~CEstimate()
{

}

bool	CEstimate::AddSampleData(vector<double> x)
{
	if (x.size() != m_nDim)
		return false;

	m_listSample.push_back(x);
	return true;
}

bool CEstimate::ClearSampleData()
{
	m_listSample.resize(0);
	return true;
}

//计算两个矢量之间的距离 , 2范数
double CEstimate::Distance(vector<double> x1, vector<double> x2)
{

	assert(x1.size() == x2.size());

	vector<double>::iterator vi1,vi2;
	
	double temp = 0.0;

	for (vi1 = x1.begin(), vi2 = x2.begin(); 
			(vi1 != x1.end()) && (vi2 != x2.end());
				vi1++,vi2++)
				{
					temp += (*vi1 - *vi2)*(*vi1 - *vi2);
				}
	

	return sqrt(temp);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -