Skip to content Skip to sidebar Skip to footer

Does Scipy Logsumexp() Deal With The Underflow Challenge?

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

Solution 1:

You can inspect the source code defining logsumexphere. (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.

Post a Comment for "Does Scipy Logsumexp() Deal With The Underflow Challenge?"