6

Does the scipy's logsumexp() implementation include the hack that prevents underflow by subtracting the maximum found value in the array from each element?

The one explained here below, where m = maxval:

enter image description here

user961627
  • 12,379
  • 42
  • 136
  • 210

1 Answers1

10

You can inspect the source code defining logsumexp here. (Note that there is a link to the source on the doc page).

You'll see:

a_max = a.max(axis=0)
...
out = log(sum(exp(a - a_max), axis=0))

So yes, scipy's logsumexp is subtracting the maximum from each element.

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677