How to efficiently create histograms from collections of point numbers