import numpy as np
datamin = -5
datamax = 5
numbins = 20
mybins = np.linspace(datamin, datamax, numbins)
myhist = np.zeros(numbins - 1, dtype='int32')
for i in range(100):
    d = np.random.randn(1000, 1)
htemp, jnk = np.histogram(d, mybins)
myhist += htemp
Numpy histogram of large arrays