[Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

Charles R Harris charlesr.harris at gmail.com
Sat Oct 17 13:20:50 EDT 2009


On Sat, Oct 17, 2009 at 9:36 AM, per freem <perfreem at gmail.com> wrote:

> hi all,
>
> in my code, i use the function 'logsumexp' from scipy.maxentropy a
> lot. as far as i can tell, this function has no vectorized version
> that works on an m-x-n matrix. i might be doing something wrong here,
> but i found that this function can run extremely slowly if used as
> follows: i have an array of log probability vectors, such that each
> column sums to one. i want to simply iterate over each column and
> renormalize it, using exp(col - logsumexp(col)). here is the code that
> i used to profile this operation:
>
> from scipy import *
> from numpy import *
> from numpy.random.mtrand import dirichlet
> from scipy.maxentropy import logsumexp
> import time
>
>
Why aren't you using logaddexp ufunc from numpy?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091017/1365e2ec/attachment.html>


More information about the NumPy-Discussion mailing list