本文整理汇总了C++中DM::at方法的典型用法代码示例。如果您正苦于以下问题:C++ DM::at方法的具体用法?C++ DM::at怎么用?C++ DM::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DM
的用法示例。
在下文中一共展示了DM::at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mutualInformationSimilarity
double mutualInformationSimilarity( std::vector<double>& entropyMap,
SimiCache& simiCache,
const DM& dataMat,
const size_t varA,
const size_t varB ) {
double result = 0.0;
size_t nVars = entropyMap.size();
size_t key = 2*nVars*varA + varB;
Entropy<EMP> entropy; // empirical entropy (estimates the probability by frequency)
JointEntropy<EMP> mutEntropy; // empirial mutual entropy;
if ( entropyMap.at(varA) < 0.0 ) {
entropyMap[varA] = entropy( dataMat.at(varA) ); // computes entropy of varA only if not already done
}
if ( entropyMap.at(varB) < 0.0 ) { // computes entropy of varB only if not already done
entropyMap[varB] = entropy( dataMat.at(varB)) ; // since this operation could be expensive
}
double minEntropyAB = std::min( entropyMap[varA], entropyMap[varB]); // takes the min
if (minEntropyAB != 0) {
double mutEntropyAB = mutEntropy( dataMat.at(varA), dataMat.at(varB) );
double mutualInfoAB = entropyMap[varA] + entropyMap[varB] - mutEntropyAB; // classic formula
double normalizedMutInfo = mutualInfoAB / minEntropyAB;
result = normalizedMutInfo;
}
return result;
}