JuliaRobotics / KernelDensityEstimate.jl

Kernel Density Estimate with product approximation using multiscale Gibbs sampling
GNU Lesser General Public License v2.1
23 stars 7 forks source link

How to modify the kernel ? #20

Closed Oudjane closed 6 years ago

Oudjane commented 6 years ago

Hi, I couldn't figure out how to modify the kernel. In particular, I would like to be able to compute gradients of the density. Thank you,

Nadia

dehann commented 6 years ago

Hi Nadia,

Changing kernels is possible, but not really built out in this package yet. I will keep in mind for future development. The main purpose of this package is to approximate the product between Gaussian kernel density estimates. The KernelDensity.jl package is more mature (although they do not estimate products) and may have more of the tools you need right now.

However, for your second question, calculating the gradients of a KDE in this package will be easiest through numerical differencing:

h = 1e-5
p = kde!(randn(100))
ep = evaluateDualTree(p,[1.0; 1+h])
dpdx = diff(ep)/h

Analytic derivative is also possible, but not all the functions are clearly defined for a general API yet. I will keep this in mind going forward also.

Thanks

Oudjane commented 6 years ago

Thank you very much for your answer !

Unfortunately the KernelDensity.jl package is not able to consider d-dimensional density estimation for d>=3. For the gradient, thank you, automatic differencing could be an issue. I will try it but I am worried about the variance of the resulting estimate. I thought it would be more efficient to pass the gaussian kernel derivative as a new kernel. Thank you again for all,

Nadia