log-sum-exp trick why not recursive
问题 I have been researching the log-sum-exp problem. I have a list of numbers stored as logarithms which I would like to sum and store in a logarithm. the naive algorithm is def naive(listOfLogs): return math.log10(sum(10**x for x in listOfLogs)) many websites including: logsumexp implementation in C? and http://machineintelligence.tumblr.com/post/4998477107/ recommend using def recommend(listOfLogs): maxLog = max(listOfLogs) return maxLog + math.log10(sum(10**(x-maxLog) for x in listOfLogs)) aka