You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let w, x be vectors. I'm interested in computing log(dot(w, exp.(x)). The current logsumexp functions can be used to compute this, but one must take log.(w)which is troublesome when w can be very small or zero. I took a look at the source and I think actually it should be straightforward to extend the current code. The end goal for this would be to implement x -> log.(K*exp.(x)) where K is a matrix and x is a vector.
What I'm not so familiar with is how to implement the reduction in Julia in an efficient manner. At a high level, the first thing that comes to mind for me is to do something like a binary operation of the type x, (y, w) -> log(exp(x) + w*exp(y)) and do a reduction over pairs of data and weights. But I'd appreciate some input on how this should be best done.
The text was updated successfully, but these errors were encountered:
There's a PR in the StatsFuns repo that implements weighted logsumexp. IIRC it was opened before this package was extracted from StatsFuns and the implementation of logsumexp was rewritten. There's also a discussion of a weighted alternative of the single-pass algorithm of logsumexp in LogExpFunctions in https://mileslucas.com/posts/weighted-logsumexp/.
Let
w, x
be vectors. I'm interested in computinglog(dot(w, exp.(x))
. The currentlogsumexp
functions can be used to compute this, but one must takelog.(w)
which is troublesome whenw
can be very small or zero. I took a look at the source and I think actually it should be straightforward to extend the current code. The end goal for this would be to implementx -> log.(K*exp.(x))
whereK
is a matrix andx
is a vector.What I'm not so familiar with is how to implement the reduction in Julia in an efficient manner. At a high level, the first thing that comes to mind for me is to do something like a binary operation of the type
x, (y, w) -> log(exp(x) + w*exp(y))
and do a reduction over pairs of data and weights. But I'd appreciate some input on how this should be best done.The text was updated successfully, but these errors were encountered: