actual_error.txt

来自「完整的模式识别库」· 文本 代码 · 共 48 行

TXT
48
字号
// function to calculate the actual error// method : actual_error// arguments : vector, vector, double// return : void// description :// Compute the actual error from the given data points and the estimated// values.//----------------------------------------------------------------public void actual_error( Vector y_estimate, Vector iset, double act_error){//	double actual_pt[];//	double estimate_pt[];		double error_value;	int j = 0;		for (int i = 0; (i < y_estimate.size() && j < iset.size() ); i++)	{		while ( ((MyPoint)y_estimate.elementAt(i)).x < ((MyPoint)iset.elementAt(j)).x )		      if ( ( i < y_estimate.size() ) && ( j < iset.size() )			 i++;	              else			 break;		if ( j < iset.size())		{		   if ( ((MyPoint)y_estimate.elementAt(i)).x == ((MyPoint)iset.elementAt(j)).x ) 		   {			// error is -			error_value = ((MyPoint)y_estimate.elementAt(i)).y - ((MyPoint)iset.elementAt(j)).y;			act_error += error_value * err_value;		    }		    if ( ((MyPoint)y_estimate.elementAt(i)).x > ((MyPoint)iset.elementAt(j)).x )		    {			double y1 = ((MyPoint)y_estimate.elementAt(i)).y;			double y2 = ((MyPoint)y_estimate.elementAt(i - 1)).y;			double x1 = ((MyPoint)y_estimate.elementAt(i)).x;			double x2 = ((MyPoint)y_estimate.elementAt(i - 1)).x;			double x_unknown = ((MyPoint)iset.elementAt(j)).x			error_value = y2 - ( (x2 - x_unknown) * ( y2 - y1) / (x2 - x1));			act_error += error_value * error_value ;		    }		    j++;		}	}		}

⌨️ 快捷键说明

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