[Numpy-discussion] Initial implementation of histogram_discrete()

David Warde-Farley dwf@cs.toronto....
Thu Nov 12 17:16:09 CST 2009


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.

David


More information about the NumPy-Discussion mailing list