Added a function for computing histogram and density -- closes #2