Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in InterpKDE #29

Open
OmriTreidel opened this issue Jul 19, 2016 · 5 comments
Open

bug in InterpKDE #29

OmriTreidel opened this issue Jul 19, 2016 · 5 comments
Labels

Comments

@OmriTreidel
Copy link

I have a kde::UnivariateKDE which is non-negative. Constructing ik = InterpKDE(kde) results in undefined grid. Even worse, calling pdf(ik, x) sometimes return negative values.

@OmriTreidel
Copy link
Author

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:

  1. pdf(ik::InterpKDE,x...) = max(0.0, ik.grid[x...])
  2. Default the interpolation in InterpKDE to Linear

@ararslan ararslan added the bug label Jul 19, 2016
@simonbyrne
Copy link
Member

I've changed KernelDensity to use Interpolations instead of Grid. Would you mind seeing if this is still an issue?

@OmriTreidel
Copy link
Author

I'm looking into it.

@AlexRobson
Copy link

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

@drrmmng
Copy link

drrmmng commented Feb 5, 2022

Is this related?
MakieOrg/AlgebraOfGraphics.jl#334

If so, there is at least a data set and two minimal working examples to reproduce this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants