kernel density estimation
bech
Note that it's not trivial. There are a handful of kernels to support, several ways to compute bandwidth defaults, etc.
Some sources of code:
1d and 2d matlab versions:
http://www.mathworks.com/matlabcentral/fileexchange/14034-kernel-densit…
http://www.mathworks.com/matlabcentral/fileexchange/17204-kernel-densit…
R:
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/density.html
Mathematica supports it via "SmoothKernelDistribution".