具体介绍见西瓜书
#include <iostream>
#include <cmath>
using namespace std;
//数据集个数 N
//算法个数 k
//第i个算法的平均序数值 ri
double calcTX2(int N,int k,double ri[])
{
double partone=(12.0*N)/(double)(k*(k+1.0));
double parttwo=0.0;
for(int i=0;i<k;i++)
{
parttwo+=ri[i]*ri[i];
}
parttwo=parttwo-k*(k+1)*(k+1)/4;
double res=partone*parttwo;
return res;
}
double TF(double TX2,int N,int k)
{
double res=(double)((N-1)*TX2)/(double)(N*(k-1)-TX2);
return res;
}
double calcCD(double qAlpha,int k,int N)
{
return qAlpha*sqrt((k*(k+1.0))/(6.0*N));
}
int main()
{
double ri[4]={3.75,3.25,1.75,1.25};
//double ri[3]={1,2.125,2.875};
int N=4;
int k=4;
cout<<"res= "<<TF(calcTX2(N,k,ri),N,k)<<endl;
cout<<"CD= "<<calcCD(2.344,k,N)<<endl;
return 0;
}