Sorry if this is a duplicate- it surely is but there are so many ways this could be asked I didn't stumble across it...
I want to convert an array to weights. The following code does it:
>>> a = np.array([1,2,3])
>>> a.astype(float) / a.sum()
array([ 0.16666667, 0.33333333, 0.5 ])
This gets really hairy for complex arrays. Is there a numpy method that will do the same?