[PYTHON MATRIX-SIG] Histogram?
Mon, 12 Aug 1996 14:51:59 -0400 (EDT)
Thanks for your help.
Are binarysearch and concatenate in the new matrix module 1.0alpha1 ?
On Mon, 12 Aug 1996, Jim Hugunin wrote:
> This is not quite optimal (O(N lg N) instead of O(N)), but it is
> adequate for my needs:
> def histogram(a, bins):
> """Calculates the histogram of the values in the 1d array a.
> bins is an array of the edges of the bins, there is one less
> bin than items in this array. Items that lie exactly on a bin
> edge have a 50/50 chance of appearing in either bin."""
> n = binarysearch(sort(a), bins)
> n = concatenate( [n, [len(a)]] )
> return n[1:]-n[:-1]
> Something like this will wind up in the standard library.
> MATRIX-SIG - SIG on Matrix Math for Python
> send messages to: firstname.lastname@example.org
> administrivia to: email@example.com
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: firstname.lastname@example.org
administrivia to: email@example.com