New version of binning() that calculates the standard deviation as well.