本文整理汇总了C++中Factor::marginal方法的典型用法代码示例。如果您正苦于以下问题:C++ Factor::marginal方法的具体用法?C++ Factor::marginal怎么用?C++ Factor::marginal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factor
的用法示例。
在下文中一共展示了Factor::marginal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
Real ExactInf::run() {
if( props.verbose >= 1 )
cerr << "Starting " << identify() << "...";
Factor P;
for( size_t I = 0; I < nrFactors(); I++ )
P *= factor(I);
Real Z = P.sum();
_logZ = std::log(Z);
for( size_t i = 0; i < nrVars(); i++ )
_beliefsV[i] = P.marginal(var(i));
for( size_t I = 0; I < nrFactors(); I++ )
_beliefsF[I] = P.marginal(factor(I).vars());
if( props.verbose >= 1 )
cerr << "finished" << endl;
return 0.0;
}
示例2: calcNewBelief
Factor MF::calcNewBelief( size_t i ) {
Factor result;
daiforeach( const Neighbor &I, nbV(i) ) {
Factor henk;
daiforeach( const Neighbor &j, nbF(I) ) // for all j in I \ i
if( j != i )
henk *= _beliefs[j];
Factor piet = factor(I).log(true);
piet *= henk;
piet = piet.marginal(var(i), false);
piet = piet.exp();
result *= piet;
}
示例3: calcMessages
void BP_dual::calcMessages() {
// calculate 'n' messages from "factor marginal / factor"
for( size_t I = 0; I < fg().nrFactors(); I++ ) {
Factor f = _ia->beliefF(I) / fg().factor(I);
diaforeach( const Neighbor &i, fg().nbF(I) )
msgN(i, i.dual) = f.marginal( fg().var(i) ).p();
}
// calculate 'm' messages and normalizers from 'n' messages
for( size_t i = 0; i < fg().nrVars(); i++ )
diaforeach( const Neighbor &I, fg().nbV(i) )
calcNewM( i, I.iter );
// recalculate 'n' messages and normalizers from 'm' messages
for( size_t i = 0; i < fg().nrVars(); i++ )
diaforeach( const Neighbor &I, fg().nbV(i) )
calcNewN(i, I.iter);
}
示例4: calcMarginal
Factor ExactInf::calcMarginal( const VarSet &vs ) const {
Factor P;
for( size_t I = 0; I < nrFactors(); I++ )
P *= factor(I);
return P.marginal( vs, true );
}