?? squaredifference.cpp
字號:
// SquareDifference.cpp: implementation of the SquareDifference class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Calculate.h"
#include "SquareDifference.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SquareDifference::SquareDifference()
{
m_nGroupCount=0;
int i=0;
for(i=0;i<MAXI;i++)
{
m_nCountInGroup[i]=0;
}
for(i=0;i<MAXI;i++)
for(int j=0;j<MAXJ;j++)
m_dDatas[i][j]=0.0;
}
SquareDifference::~SquareDifference()
{
}
double SquareDifference::GetSumX()
{
double Rel=0.0;
for(int i=0;i<m_nGroupCount;i++)
{
for(int j=0;j<m_nCountInGroup[i];j++)
{
Rel+=m_dDatas[i][j];
}
}
return Rel;
}
int SquareDifference::GetSumN()
{
int Rel=0;
for(int i=0;i<m_nGroupCount;i++)
{
Rel+=m_nCountInGroup[i];
}
return Rel;
}
double SquareDifference::GetAverageX()
{
double GroupSum=0.0;
double TotalSum=0.0;
for(int i=0;i<m_nGroupCount;i++)
{
for(int j=0;j<m_nCountInGroup[i];j++)
{
GroupSum+=m_dDatas[i][j];
}
if(m_nCountInGroup[i]==0.0)
return 0.0;
TotalSum+=GroupSum/(double)m_nCountInGroup[i];
GroupSum=0.0;
}
if(m_nGroupCount==0.0)
return 0.0;
return TotalSum/(double)m_nGroupCount;
}
double SquareDifference::GetSquareSumX()
{
double Rel=0.0;
for(int i=0;i<m_nGroupCount;i++)
{
for(int j=0;j<m_nCountInGroup[i];j++)
{
Rel+=m_dDatas[i][j]*m_dDatas[i][j];
}
}
return Rel;
}
double SquareDifference::GetTotalSS()
{
double Rel=0.0;
if(GetSumN()==0)
return Rel;
Rel=GetSquareSumX()-GetSumX()*GetSumX()/(double)GetSumN();
return Rel;
}
int SquareDifference::GetTotalV()
{
return GetSumN()-1;
}
double SquareDifference::GetGroupSS()
{
double Rel=0.0,tmp=0.0;
for(int i=0;i<m_nGroupCount;i++)
{
for(int j=0;j<m_nCountInGroup[i];j++)
{
if(m_nCountInGroup[i]==0.0)
return 0.0;
tmp+=m_dDatas[i][j];//*m_dDatas[i][j]/(double)m_nCountInGroup[i];
}
Rel+=tmp*tmp/(double)m_nCountInGroup[i];
tmp=0.0;
}
if(GetSumN()==0)
return 0.0;
Rel=Rel-GetSumX()*GetSumX()/(double)GetSumN();
return Rel;
}
int SquareDifference::GetGroupV()
{
return m_nGroupCount-1;
}
double SquareDifference::GetGroupInnerSS()
{
return GetTotalSS()-GetGroupSS();
}
int SquareDifference::GetGroupInnerV()
{
return GetSumN()-m_nGroupCount;
}
double SquareDifference::GetMSGroup()
{
return GetGroupSS()/(double)GetGroupV();
}
double SquareDifference::GetMSGroupInner()
{
return GetGroupInnerSS()/(double)GetGroupInnerV();
}
double SquareDifference::GetF()
{
return GetMSGroup()/GetMSGroupInner();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -