is there a more efficient way to take an average of an array in prespecified bins? for example, i have an arra