It's much faster:
$ time python -c 'import numpy; sum(numpy.arange(int(1e6)))'
real 0m3.312s
user 0m3.188s
sys 0m0.118s
$ time python -c 'import numpy; numpy.arange(int(1e6)).sum()'
real 0m0.878s
user 0m0.753s
sys 0m0.122s
bin_is = numpy.floor((data - self.bin_edges[0])/bin_width)
self.counts = []
for i in range(len(self.bin_edges)-1):
- self.counts.append(sum(bin_is == i))
+ self.counts.append(sum(bin_is == i).sum())
self.total = float(len(data)) # some data might be outside the bins
self.mean = data.mean()
self.std_dev = data.std()