# Function that is a good fit to the plot made with SmoothHistogram

How can I find a function that fits the plot from the SmoothHistogram function?

For instance if I have data like this and plot a Smooth Histogram, how can I get a function that fits the plot?

data = {4, 4, 4, 4, 1, 1, 4, 1, 5, 5, 5, 5, 5};
SmoothHistogram[data]


-

This is one approach yielding an interpolating function:

  data = {4, 4, 4, 4, 1, 1, 4, 1, 5, 5, 5, 5, 5};
f = Interpolation[
DeleteDuplicates[(List @@
First@First@
Cases[ SmoothHistogram[data] , _Line,
Infinity]), #1[[1]] == #2[[1]] &]]

Plot[f[x], {x, 0, 6.5}]


-
I appreciate the accept, buy @szabolcs answer really is the best. –  george2079 Jun 2 at 13:12
SmoothHistogram uses kernel density estimation. So the correct and direct way to obtain the function is to construct a SmoothKernelDistribution, then take its PDF.
distr = SmoothKernelDistribution[data]