Implement histogram computation.