Added some density estimation code