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

📄 squaredifference.cpp

📁 老婆写医学实验论文
💻 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 + -