Skip to content

farr/PointwiseKDEs.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PointwiseKDEs

One thing lacking currently in Julia is a generic Gaussian KDE in multiple dimensions, similar to scipy's gaussian_kde. This package provides exactly that: a constructor that takes a matrix of points in arbitrary dimension and constructs the Gaussian KDE density as a MultivariateDistribution from Distributions.jl. Bandwidth is chosen following Scott's rule.

Unlike KernelDensity.jl, the cost to evaluate the density from a PointwiseKDE scales linearly with the number of input points; the cost to draw a point from the KDE is constant.

Construct a KDE

> using PointwiseKDE
> ndim = 3
> npts = 1000
> pts = randn(ndim, npts)
> kde = PointwiseKDE(pts)

Draw From the KDE

> draw_pt = rand(kde) # draw one sample
> draw_pts = rand(kde, 100) # A (ndim, 100) matrix of draws

Compute KDE densities:

> rand_pt = randn(3)
> loglike = logpdf(kde, rand_pt)

About

Analog of scipy's gaussian_kde in Julia.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages