add a function to automatically bin an array along a choosen dimension in n bins of binSize elements