本文整理汇总了C++中CFactor::IsFactorsDistribFunEqual方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactor::IsFactorsDistribFunEqual方法的具体用法?C++ CFactor::IsFactorsDistribFunEqual怎么用?C++ CFactor::IsFactorsDistribFunEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactor
的用法示例。
在下文中一共展示了CFactor::IsFactorsDistribFunEqual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSetStatistics
int testSetStatistics()
{
int ret = TRS_OK;
float eps = 0.1f;
int seed = pnlTestRandSeed();
pnlSeed( seed );
CBNet *pBNet = pnlExCreateCondGaussArBNet();
CModelDomain *pMD = pBNet->GetModelDomain();
CGraph *pGraph = CGraph::Copy(pBNet->GetGraph());
CBNet *pBNet1 = CBNet::CreateWithRandomMatrices( pGraph, pMD );
pEvidencesVector evidences;
int nEvidences = pnlRand( 3000, 4000);
pBNet->GenerateSamples( &evidences, nEvidences );
int i;
for( i = 0; i < nEvidences; i++)
{
//evidences[i]->MakeNodeHiddenBySerialNum(0);
}
CEMLearningEngine *pLearn = CEMLearningEngine::Create(pBNet1);
pLearn->SetData( nEvidences, &evidences.front() );
pLearn->SetMaxIterEM();
pLearn->Learn();
for( i = 0; i < pBNet->GetNumberOfFactors(); i++ )
{
if( ! pBNet->GetFactor(i)->IsFactorsDistribFunEqual(pBNet1->GetFactor(i), eps))
{
ret = TRS_FAIL;
pBNet->GetFactor(i)->GetDistribFun()->Dump();
pBNet1->GetFactor(i)->GetDistribFun()->Dump();
}
}
CDistribFun *pDistr;
const CMatrix<float>* pMat;
CFactor *pCPD;
pDistr = pBNet1->GetFactor(0)->GetDistribFun();
pMat = pDistr->GetStatisticalMatrix(stMatTable);
pCPD = pBNet->GetFactor(0);
pCPD->SetStatistics(pMat, stMatTable);
pCPD->ProcessingStatisticalData(nEvidences);
if( ! pCPD->IsFactorsDistribFunEqual(pBNet1->GetFactor(0), 0.0001f) )
{
ret = TRS_FAIL;
}
pDistr = pBNet1->GetFactor(1)->GetDistribFun();
int parentVal;
pCPD = pBNet->GetFactor(1);
parentVal = 0;
pCPD->SetStatistics(pMat, stMatCoeff);
pMat = pDistr->GetStatisticalMatrix(stMatMu, &parentVal);
pCPD->SetStatistics(pMat, stMatMu, &parentVal);
pMat = pDistr->GetStatisticalMatrix(stMatSigma, &parentVal);
pCPD->SetStatistics(pMat, stMatSigma, &parentVal);
parentVal = 1;
pMat = pDistr->GetStatisticalMatrix(stMatMu, &parentVal);
pCPD->SetStatistics(pMat, stMatMu, &parentVal);
pMat = pDistr->GetStatisticalMatrix(stMatSigma, &parentVal);
pCPD->SetStatistics(pMat, stMatSigma, &parentVal);
pCPD->ProcessingStatisticalData(nEvidences);
if( ! pCPD->IsFactorsDistribFunEqual(pBNet1->GetFactor(1), eps) )
{
ret = TRS_FAIL;
}
for( i = 0; i < nEvidences; i++)
{
delete evidences[i];
}
delete pLearn;
//.........这里部分代码省略.........