JuliaStats / StatsFuns.jl

Mathematical functions related to statistics.
Other
235 stars 40 forks source link

add logsubexp(x,y) #95

Closed cossio closed 4 years ago

cossio commented 4 years ago

This is useful in some contexts. Other libraries have this, for example, https://www.tensorflow.org/probability/api_docs/python/tfp/math/log_sub_exp

If this gets merged please tag a release (I bumped the version here).

cossio commented 4 years ago

Merge?

cossio commented 4 years ago

@nalimilan Thank you for taking a look! Nothing left to merge? Also please tag a release with this.

nalimilan commented 4 years ago

After considering this again, I found out that x log x has no limit in 0 for complex numbers. So the docstring isn't correct for them. How about just mentioning that we return zero for zero (for both xlogx and xlogy, like Numpy does? We could still mention that it's consistent with the limit for reals. See also the previous discussion we had about this (I just found it again!): https://github.com/JuliaStats/StatsFuns.jl/pull/87#discussion_r362096613

cossio commented 4 years ago

Good point @nalimilan. Done.

cossio commented 4 years ago

Please tag a release with this. Thanks!