[Numpy-discussion] Initial implementation of histogram_discrete()

josef.pktd@gmai... josef.pktd@gmai...
Thu Nov 12 17:25:34 CST 2009


On Thu, Nov 12, 2009 at 6:16 PM, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> On 12-Nov-09, at 6:09 PM, josef.pktd@gmail.com wrote:
>
>> On Thu, Nov 12, 2009 at 6:00 PM, Priit Laes <plaes@plaes.org> wrote:
>>> Hey,
>>>
>>> I cooked up an initial implementation for one-dimensional
>>> histogram_discrete().
>>>
>>> Example:
>>>
>>>>> import numpy
>>>>> numpy.histogram_discrete([-1, 9, 9, 0, 3, 5, 3])
>>> array([1, 1, 0, 0, 2, 0, 1, 0, 0, 0, 2])
>>>>> numpy.histogram_discrete([-99999, 99999])
>>> array([1, 0, 0, ..., 0, 0, 1])
>>>
>>> Suggestions, criticism? :)
>
>> Is there a difference to numpy.bincount ?
>
>
> Time to add to this to the FAQ (FWIW I've reinvented the wheel a
> number of times too).
>
> Though, np.bincount does not handle negatives -- I kind of like it
> that way though.

If I could make a related wish, I wish np.bincount to take also a 2d
array as weights.

Josef

>
> David
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list