[PYTHON MATRIX-SIG] Histogram?

Jean-Bernard ADDOR jbaddor@phy.ulaval.ca
Mon, 12 Aug 1996 14:51:59 -0400 (EDT)


Thanks for your help.

Are binarysearch and concatenate in the new matrix module 1.0alpha1 ?

	Jean-Bernard


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.
> 
> -Jim
> 
> =================
> MATRIX-SIG  - SIG on Matrix Math for Python
> 
> send messages to: matrix-sig@python.org
> administrivia to: matrix-sig-request@python.org
> =================
> 


=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================