source code to compute the histogram of the density