Kernel density estimation status

Sure, that would be fun to look at. Here is what I am seeing currently, and helping with these issues might be more productive. Maybe you aren’t seeing these and it’s just me, in which case figuring out what is causing it may be of value in improving stability.

example code that is failing:

y = randn(100_000)
o = ash(y; rng = -5:.1:5)

MethodError: no method matching ash(:Array{Float64,1}; rng=-5.0:0.1:5.0)

Just using the package gives a list of deprecated syntax. Examples:

WARNING: deprecated syntax “typealias VecF Vector{Float64}” at C:\Users\pmancini.julia\v0.6\AverageShiftedHistograms\src\AverageShiftedHistograms.jl:13.
Use “const VecF = Vector{Float64}” instead.

WARNING: deprecated syntax “typealias MatF Matrix{Float64}” at C:\Users\pmancini.julia\v0.6\AverageShiftedHistograms\src\AverageShiftedHistograms.jl:14.
Use “const MatF = Matrix{Float64}” instead.

WARNING: deprecated syntax “typealias AVecF AbstractVector{Float64}” at C:\Users\pmancini.julia\v0.6\AverageShiftedHistograms\src\AverageShiftedHistograms.jl:15.
Use “const AVecF = AbstractVector{Float64}” instead.

WARNING: deprecated syntax “typealias AMatF AbstractMatrix{Float64}” at C:\Users\pmancini.julia\v0.6\AverageShiftedHistograms\src\AverageShiftedHistograms.jl:16.
Use “const AMatF = AbstractMatrix{Float64}” instead.

WARNING: deprecated syntax “abstract ASH” at C:\Users\pmancini.julia\v0.6\AverageShiftedHistograms\src\AverageShiftedHistograms.jl:18.
Use “abstract type ASH end” instead.

If I can help with any of these and make the package more useable and stable as is, adding the pdf function would then be easier.

You must not be on master. Try Pkg.checkout("AverageShiftedHistograms"). There’s a PR to get the updates into Metadata as well.

1 Like

Lets give it a try… time passes… [Jeopardy theme song plays]
OK, fewer deprecation warning. Code runs.
So much better. Can I iterate the resulting Ash object? I can’t seem to get it to plot in Gadfly. I poked it a bit and didn’t see an obvious method for getting the values. However. Damn. It was fast. Much faster than the other methods I’ve used.

I still need to finish the docs…

Try

a = ash(y)
xvals, densityvals = xy(a) 

Bueno!

p1

OK. I will study your code and see if can get a start on a PDF based function.

It’s cool that you also put plot recipes in the package! I’ll try it out soon as I also am a bit frustrated by kernel density lack of speed. There already is one recipe for kernel density here so that

plot(kde(args...))

makes a line plot for 1D density and a contour plot for 2D density. The seriestype can be changed manually so that for example:

heatmap(kde(args...))

would give the heatmap, surface the surface and so on…

Could the ash plot recipe behavior be changed to be consistent?

About the 1D recipe, it’d be nice to be consistent, but it’s also true that you have two things to show. Would there be an equivalent plot to that for kernel density? Also, is there an easy way to not display the :sticks series? I guess it becomes confusing when splitting data and displaying several ash densities in the same plot.

3 Likes

I’d like to revive this topic to get an up-to-date overview of the available packages for doing this.

FWIW, I need to plot the joint PDF of model output vs observations in my research quite often, so I’m mostly interested in the 2D case. Previously, as a MATLAB user, I was using kde2d.m (source on Mathworks). In Julia, I have been using KernelDensity.jl lately, but I think I preferred the bandwith selection algorithm of kde2d.m. So I started to try to translate kde2d.m to Julia (see this small gist) but then I thought that this would probably be done much better by one of the KDE-package developers! Maybe one of you wants to add this algorithm to his package?

@juliohm, whatever answers we get, it would be great if you could update the initial post with a quick overview! (Maybe you just have to select a good answer if someone writes it up below?)

1 Like

I have used KernelDensity.jl for bivariate densities. It is the only package that I am aware of for doing it. If there is something you dislike about it, I think your best bet would be to submit issues/PRs to that package.

1 Like

Well I just found this issue :slight_smile: But not sure if it will be fruitful…

Incase anyone finds this old thread.

New multidimensional KDE

8 Likes

Package Jchemo, also, proposes multivariate (multiplicative) KDE

using Jchemo
?dmkern

fda dmkern iris

4 Likes