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

Make KDE a distribution and implement other Distributions method #58

Open
matbesancon opened this issue Sep 12, 2018 · 7 comments
Open

Comments

@matbesancon
Copy link
Member

It would be nice to have:

  • cdf using QuadGK? Or StatsBase.ecdf?
  • quantile using cdf with bijection method
@tbeason
Copy link

tbeason commented Feb 12, 2020

I'm going to bump this thread. In addition to pdf, shouldn't other functions like mean, std, quantile, cdf, etc... be supported as well?

@mkborregaard
Copy link

Yes this sounds like an obviously good improvement.

@ClaudMor
Copy link

ClaudMor commented Feb 1, 2021

Yes, it would also be nice to have a rand method.

@Yuan-Ru-Lin
Copy link

Also loglikelihood for whoever needs to perform maximum-likelihood estimation with the resulting KDE.

@jaksle
Copy link
Contributor

jaksle commented Jan 16, 2024

I was just looking at the internals of this library, checking other things and I noticed this. Unfortunately, KernelDensity.jl was not designed with such features in mind. It does not store information required to effectively calculate kernel-based features other than the pdf.

What one can do is to introduce a new interface which does store it, make a new type like KernelEstimate <: Distribution which stops one step before calculating the pdf and stores all the parameters of the fit. Perhaps it can be done even better, as I see Distributions.jl has MixtureModel implemented and kde is just a fitted mixture. I'll think about this.

@alonsoC1s
Copy link

Would implementing the basic interface for a Sampleable from Distributions.jl be feasible? It would be nice to draw sampes with rand as @ClaudMor mentioned. As far as I can tell, it only requieres extending a few methods

@jaksle
Copy link
Contributor

jaksle commented Jun 20, 2024

@alonsoC1s Alas, no. The reason is this library has a bad structure. To sample from the KDE you need the parameters of the fit. Here, they are calculated inside algorithm, but the are not stored nor returned. The only thing it stores are the values of estimated pdf at discrete set of points.

You can sample from that, but I would not recommend it, it would be an ugly approximation prone to strange errors.

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

No branches or pull requests

7 participants