# SmoothHistogram with sharp boundary [duplicate]

When using SmoothHistogram (to plot probability distribution function), I noticed that the edge of the figure is automatically smoothed towards zero probability. However, in some probability distributions (or some data), this is not the case. For example,

SmoothHistogram[RandomVariate[GammaDistribution[1, 2], 10000]]


Note that at nearly zero value of x-axis, the probability distribution drops. This is incorrect. To see that, here is the result from Histogram, which shows correctly the sharp boundary:

Histogram[RandomVariate[GammaDistribution[1, 2], 10000]]


Note that the Histogram plot is correct, as one can check using

Plot[PDF[GammaDistribution[1, 2], x], {x, 0, 20}, Filling -> Axis]


Is it possible to tell SmoothHistogram not trying to interpolate the end points with zero?

-

## marked as duplicate by Kuba, Rahul, bobthechemist, Andy Ross, m_goldbergMay 2 '14 at 18:51

I believe my answer to this question is what you are looking for. – Andy Ross May 2 '14 at 14:17
@Kuba : I didn't... Why it is strange :) – Yi Wang May 2 '14 at 14:37
@AndyRoss : Thanks a lot! Yes, this is exactly what I want. I think this question can be labelled as duplicated. Sorry I searched but haven't been able to find this post until you point out. – Yi Wang May 2 '14 at 14:38
@Kuba I see. Thanks :) – Yi Wang May 2 '14 at 14:39

The nature of the kernel smoothing process will not allow you to have a discontinuity. If you use SmoothKernelDistribution, then you can set the shape of the kernel used for the smoothing (SmoothHistogram doesn't seem to have this option). For your problem, you could choose the kernel to be (for instance) a decaying exponential and then you would be smoothing only to the right.
data = RandomVariate[GammaDistribution[1, 2], 10000]; d2 =