X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classify.cpp;h=8aa3cdb381ed7a389667ce61962d47cefac15ddd;hb=90708fe9701e3827e477c82fb3652539c3bf2a0d;hp=459c90f9ddd769628b0fc9061e7bd504a88b2900;hpb=ea4f373c28543cd1002b0dd7dc6e55c526647d59;p=mothur.git diff --git a/classify.cpp b/classify.cpp index 459c90f..8aa3cdb 100644 --- a/classify.cpp +++ b/classify.cpp @@ -354,3 +354,37 @@ vector Classify::parseTax(string tax) { } /**************************************************************************************************/ +double Classify::getLogExpSum(vector probabilities, int& maxIndex){ + try { + // http://jblevins.org/notes/log-sum-exp + + double maxProb = probabilities[0]; + maxIndex = 0; + + int numProbs = (int)probabilities.size(); + + for(int i=1;i= maxProb){ + maxProb = probabilities[i]; + maxIndex = i; + } + } + + double probSum = 0.0000; + + for(int i=0;ierrorOut(e, "Classify", "getLogExpSum"); + exit(1); + } +} + +/**************************************************************************************************/ +