X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=classify.cpp;h=8aa3cdb381ed7a389667ce61962d47cefac15ddd;hp=459c90f9ddd769628b0fc9061e7bd504a88b2900;hb=e8e13c129ba8184ec5932a090773f353f3ae3406;hpb=035f86272c776e1cccaa47021e26782e49cd41e7 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); + } +} + +/**************************************************************************************************/ +