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

josef.pktd@gmai... josef.pktd@gmai...
Sat Oct 17 19:07:15 CDT 2009


On Sat, Oct 17, 2009 at 8:00 PM,  <josef.pktd@gmail.com> wrote:
> On Sat, Oct 17, 2009 at 7:46 PM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
>>
>>
>> On Sat, Oct 17, 2009 at 5:27 PM, <josef.pktd@gmail.com> wrote:
>>>
>>> On Sat, Oct 17, 2009 at 2:02 PM, Charles R Harris
>>> <charlesr.harris@gmail.com> wrote:
>>> >
>>> >
>>> > On Sat, Oct 17, 2009 at 11:54 AM, <josef.pktd@gmail.com> wrote:
>>> >>
>>> >> On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris
>>> >> <charlesr.harris@gmail.com> wrote:
>>> >> >
>>> >> >
>>> >> > On Sat, Oct 17, 2009 at 9:36 AM, per freem <perfreem@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?
>>> >>
>>> >> Maybe because it is difficult to find, it doesn't have its own docs
>>> >> entry.
>>> >>
>>> >> e.g. no link to logaddexp in
>>> >>
>>> >> http://docs.scipy.org/doc/numpy/reference/ufuncs.html#math-operations
>>> >>
>>> >> I have no idea, why it is different from the other ufuncs in the docs
>>> >> (and help file).
>>> >> It shows up correctly in the docs editor, but not in the numpy 1.3 and
>>> >> online docs.
>>> >>
>>> >
>>> > That's curious, none of the five ufuncs added in 1.3 have links even
>>> > though
>>> > they all have documentation.
>>>
>>> I found that they are missing from routines.math
>>> http://docs.scipy.org/numpy/docs/numpy-docs/reference/routines.math.rst/
>>>
>>> I added logaddexp, logaddexp2 and exp2
>>>
>>> What else?
>>>
>>
>> Thanks. Also deg2rad, rad2deg, trunc, and copysign need to be added. Is that
>> something that can be done in svn, or automatically, or does it need to be
>> done on docs site?
>>
>> Chuck
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
> I can do it in the doc editor. I can see from the ufuncs docs where they belong.
>
> Josef
>

here are the changes, if you wnat to check the location

Josef

http://docs.scipy.org/numpy/docs/numpy-docs/reference/routines.math.rst/diff/svn/cur/


More information about the NumPy-Discussion mailing list