Open OmriTreidel opened 8 years ago
I've traced the undefined grid to the default boundary condition bc::Type{BC}=BCnan
. Is that really the most sensible default?
Also, the negative pdf results from the quadratic interpolation. There are several ways this can be fixed:
pdf(ik::InterpKDE,x...) = max(0.0, ik.grid[x...])
I've changed KernelDensity to use Interpolations instead of Grid. Would you mind seeing if this is still an issue?
I'm looking into it.
Old thread, but I believe that I'm also hitting a variant of this when deploying in the wild with some heavy tailed data:
MWE:
rx = [randn(95,); 10^1; 10^2; 10^3; 10^4; 10^5]
ry = randn(100,)
kxy = KernelDensity.kde((rx, ry))
kx = KernelDensity.kde(rx)
display(pdf(kx, kxy.x)[1:10])
10-element Vector{Float64}:
0.018119920780898854
2.824161390572578e-10
-1.52690720751668e-8
-1.3976374893253972e-7
1.3678176032328834e-11
1.7180241491468265e-11
1.914539912867148e-11
2.0346765855877925e-11
2.1132222284907084e-11
2.1673349260840836e-11
Is this related? https://github.com/JuliaPlots/AlgebraOfGraphics.jl/issues/334
If so, there is at least a data set and two minimal working examples to reproduce this.
I have a
kde::UnivariateKDE
which is non-negative. Constructingik = InterpKDE(kde)
results in undefined grid. Even worse, callingpdf(ik, x)
sometimes return negative values.