[SciPy-User] Sort b according to histogram(a)

Alan G Isaac aisaac at american.edu
Wed Dec 16 15:59:22 EST 2009


On 12/16/2009 3:21 PM, Arthur M. Greene wrote:
> x = (1,4,7), y = (200,100,1000), edges = (0,5,10)
> counts = (2,1), ydata = (150,1000)


>>> gety = np.where(np.equal.outer(np.arange(1,len(edges)),np.digitize(x,edges)),y,0)
>>> counts = (gety>0).sum(axis=1)
>>> gety.sum(axis=1) / counts
array([ 150, 1000])

fwiw,
Alan Isaac



More information about the SciPy-User mailing list