panlanfeng / KernelEstimator.jl

The julia package for nonparametric density estimate and regression
Other
26 stars 6 forks source link

zero density error at bounds #10

Open drbenvincent opened 3 years ago

drbenvincent commented 3 years ago

There are examples of situations where the density at a bound is returned as zero when it shouldn't be.

An example:

using KernelEstimator, Distributions, StatsPlots

dist = Exponential(1)
x = rand(dist, 1000);
histogram(x, normalize=:pdf, alpha=0.2, label=false)
xs = LinRange(0, maximum(x)+1, 399);
den = kerneldensity(x, xeval=xs, kernel=gammakernel, lb=0.0, ub=Inf);
plot!(xs, den, lw=2, colour=:red, label="kerneldensity")
plot!(xs, pdf(dist, xs), color=:black, lw=2, label="true")
Screenshot 2021-02-13 at 13 21 23

and all(den .> 0) results in false