JuliaStats / KernelDensity.jl

Kernel density estimators for Julia
Other
177 stars 40 forks source link

possibly add sampler from KDE #23

Closed rawls238 closed 6 years ago

rawls238 commented 8 years ago

@simonbyrne

This adds naive rejection sampling on top of the pdf interpolation functions. Still want to add tests and verify that this actually works, but wanted to put this up for a PR to see if there were any objections to this first.

simonbyrne commented 8 years ago

Possibly, but there might be more efficient ways to go about this. For one thing, if you have the original data, you can just sample from that, then convolve with the kernel. However we don't store the original data.

For one thing, you certainly don't want to call pdf on a kde object in a loop: you should construct the interpolation object first. It might also be more efficient to do some sort of inverse transform or table lookup.