chstwo.cpp

来自「Numerical recipes in C++」· C++ 代码 · 共 21 行

CPP
21
字号
#include "nr.h"

void NR::chstwo(Vec_I_DP &bins1, Vec_I_DP &bins2, const int knstrn, DP &df,
	DP &chsq, DP &prob)
{
	int j;
	DP temp;

	int nbins=bins1.size();
	df=nbins-knstrn;
	chsq=0.0;
	for (j=0;j<nbins;j++)
		if (bins1[j] == 0.0 && bins2[j] == 0.0)
			--df;
		else {
			temp=bins1[j]-bins2[j];
			chsq += temp*temp/(bins1[j]+bins2[j]);
		}
	prob=gammq(0.5*df,0.5*chsq);
}

⌨️ 快捷键说明

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