Tim Michelsen wrote: > Hello, > I need some advice on histograms. > If I interpret the documentation [1, 2] for numpy.histogram correctly, the > result of the function is a count of the occurences sorted into each bin. > > (n, bins) = numpy.histogram(v, bins=50, normed=1) > > But how can I apply another function on these values stacked in each bin? > Like summing them up or building averages?
Hi Tim, If you just want to sum and/or average (= sum / count), you can shortcut this using the weights parameter of numpy.histogram, e.g. something like: data = numpy.random.random((100,)) countsPerBin = numpy.histogram(data) sumsPerBin = numpy.histogram(data, weights=data) averagePerBin = sumsPerBin / countsPerBin Regards, Vincent. > > Thanks, > Timmie > > [1] http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html > [2] > http://www.scipy.org/Tentative_NumPy_Tutorial#head-aa75ec76530ff51a2e98071adb7224a4b793519e _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion