Changed name of output of LogSumExp

This commit is contained in:
btracey
2013-07-24 00:09:10 -07:00
parent 8f745d43d4
commit 7fac45e6a9

View File

@@ -154,7 +154,7 @@ func LogSpan(dst []float64, l, u float64) {
} }
// Logsumexp returns the log of the sum of the exponentials of the values in s // Logsumexp returns the log of the sum of the exponentials of the values in s
func LogSumExp(s []float64) (logsumexp float64) { func LogSumExp(s []float64) (lse float64) {
// Want to do this in a numerically stable way which avoids // Want to do this in a numerically stable way which avoids
// overflow and underflow // overflow and underflow
// First, find the maximum value in the slice. // First, find the maximum value in the slice.
@@ -171,10 +171,10 @@ func LogSumExp(s []float64) (logsumexp float64) {
// compute the sumexp part // compute the sumexp part
for _, val := range s { for _, val := range s {
logsumexp += math.Exp(val) lse += math.Exp(val)
} }
// Take the log and add back on the constant taken out // Take the log and add back on the constant taken out
logsumexp = math.Log(logsumexp) + maxval lse = math.Log(lse) + maxval
return logsumexp return logsumexp
} }