[Numpy-discussion] histogram for discrete data
josef.pktd at gmail.com
josef.pktd at gmail.com
Sun Dec 6 07:52:55 EST 2009
2009/12/6 Ernest Adrogué <eadrogue at gmx.net>:
> Hi,
>
> A few weeks ago there was a discussion about a
> histogram_discrete() function --sorry for starting a new
> thread but I have lost the mails.
>
> Somebody pointed out that bincount() already can be used
> to histogram discrete data (except that it doesn't work
> with negative values).
>
> I have just discovered a function in scipy.stats called
> itemfreq() that does handle negative values.
>
> In [17]: scipy.stats.itemfreq([-1,-1,0,5])
> Out[17]:
> array([[-1., 2.],
> [ 0., 1.],
> [ 5., 1.]])
bincount is a fast c function, stats.itemfreq uses a slow python loop.
The latter should be very slow for large arrays.
stats.itemfreq works also on floats, but not on strings (which should be a bug).
Josef
> Bye.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list