Implement density computation using histogram.