* @param probMaps
* list of probability distributions
* @return
*/
public static HMapSFW combineProbMaps(float threshold, float scale, List<PairOfFloatMap> probMaps) {
HMapSFW combinedProbMap = new HMapSFW();
int numDistributions = probMaps.size();
// get a combined set of all translation alternatives
// compute normalization factor when sum of weights is not 1.0
Set<String> translationAlternatives = new HashSet<String>();
float sumWeights = 0;
for (int i=0; i < numDistributions; i++) {
HMapSFW dist = probMaps.get(i).getMap();
float weight = probMaps.get(i).getWeight();
// don't add vocabulary from a distribution that has 0 weight
if (weight > 0) {
translationAlternatives.addAll(dist.keySet());
sumWeights += weight;
}
}
// normalize by sumWeights
for (String e : translationAlternatives) {
float combinedProb = 0f;
for (int i=0; i < numDistributions; i++) {
HMapSFW dist = probMaps.get(i).getMap();
float weight = probMaps.get(i).getWeight();
combinedProb += (weight/sumWeights) * dist.get(e); // Prob(e|f) = weighted average of all distributions
}
combinedProb *= scale;
if (combinedProb > threshold) {
combinedProbMap.put(e, combinedProb);
}