I am using KDE with a modified metric for the distance. The PDF is as expected (see below: color is the probability and the dot is the point used to fit the KDE). But due to the new metric, I cannot use the usual sampling methods as they suppose a gaussian kernel with $(||\textbf{x}-\textbf{x}_i||)$. Here I have like something like $1/(||\textbf{x}-\textbf{x}_i||)$. So, the new kernel would looks like:
$$K(\textbf{x}-\textbf{x}_i) = \exp\left(\frac{-1}{||\textbf{x}-\textbf{x}_i||*h}\right)$$
This kernel does not integrate to 1 so I bound it in the unit hypercube and I want to sample in this hypercube.
- How to generate new sample in this context?
From what I read (Find CDF from an estimated PDF (estimated by KDE), for instance), I have to come up with the multivariate inverse CDF.
- Is there a simple way to do this?
For now I just use a hack which consists in:
- Sample the multivariate space and get PDF values
- Then I use these two information with a uniform random generator to give me a sample.
It works but will get the curse of dimensionality. Something like this: https://stackoverflow.com/q/25642599
Even the CDF in a multivariate space would be enough I guess as I would be able to use some fixed point for example to do the inverse.
EDIT
Here is the result of this experiment. Color is the probability, black point is the point used for fitting the KDE and red points are samples generated using Metropolis-Hasting MCMC.


rnormand this uses the CDF If I'm correct). But this will not work in my case as I do not have this PDF. When I write the Kernel its like K(x, y) = f(x, y) but nothing like K(n). If you have some simple code this could really help because here I just do not get it. Thanks – tupui Jun 06 '18 at 13:53rkernel <- function(n) rnorm(n, sd=width) ;sample(x, n, replace=TRUE) + rkernel(n). Thernorm()is only valid for the classical gaussian Kernel. If I have something else, this will not work. Or explain it to me if I am wrong. I told everyone I am not a mathematician so as you seem to know, change this code so it answers. – tupui Jun 19 '18 at 14:32rnormby any sampling function you like, period. It's that simple.Ritself offers numerous examples and threads on this site describe literally hundreds more ways to sample from distributions. – whuber Jun 19 '18 at 14:50rnormthere is a call to inverse CDF of the normal distribution. In this case, the distribution is not normal. So no there is no solution on the shelf and I have to do rejection sampling. – tupui Jun 19 '18 at 14:53