• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    Julia
  • License
    Other
  • Created over 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kernel density estimators for Julia

KernelDensity.jl

CI Coverage Status

Kernel density estimators for Julia.

Usage

Univariate

The main accessor function is kde:

U = kde(data)

will construct a UnivariateKDE object from the real vector data. The optional keyword arguments are

  • boundary: the lower and upper limits of the kde as a tuple. Due to the fourier transforms used internally, there should be sufficient spacing to prevent wrap-around at the boundaries.
  • npoints: the number of interpolation points to use. The function uses fast Fourier transforms (FFTs) internally, so for optimal efficiency this should be a power of 2 (default = 2048).
  • kernel: the distributional family from Distributions.jl to use as the kernel (default = Normal). To add your own kernel, extend the internal kernel_dist function.
  • bandwidth: the bandwidth of the kernel. Default is to use Silverman's rule.

The UnivariateKDE object U contains gridded coordinates (U.x) and the density estimate (U.density). These are typically sufficient for plotting. A related function

kde_lscv(data)

will construct a UnivariateKDE object, with the bandwidth selected by least-squares cross validation. It accepts the above keyword arguments, except bandwidth.

There are also some slightly more advanced interfaces:

kde(data, midpoints::R) where R<:AbstractRange

allows specifying the internal grid to use. Optional keyword arguments are kernel and bandwidth.

kde(data, dist::Distribution)

allows specifying the exact distribution to use as the kernel. Optional keyword arguments are boundary and npoints.

kde(data, midpoints::R, dist::Distribution) where R<:AbstractRange

allows specifying both the distribution and grid.

Bivariate

The usage mirrors that of the univariate case, except that data is now either a tuple of vectors

B = kde((xdata, ydata))

or a matrix with two columns

B = kde(datamatrix)

Similarly, the optional arguments all now take tuple arguments: e.g. boundary now takes a tuple of tuples ((xlo,xhi),(ylo,yhi)).

The BivariateKDE object B contains gridded coordinates (B.x and B.y) and the bivariate density estimate (B.density).

Interpolation

The KDE objects are stored as gridded density values, with attached coordinates. These are typically sufficient for plotting (see above), but intermediate values can be interpolated using the Interpolations.jl package via the pdf method (extended from Distributions.jl).

pdf(k::UnivariateKDE, x)
pdf(k::BivariateKDE, x, y)

where x and y are real numbers or arrays.

If you are making multiple calls to pdf, it will be more efficient to construct an intermediate InterpKDE to store the interpolation structure:

ik = InterpKDE(k)
pdf(ik, x)

InterpKDE will pass any extra arguments to interpolate.

More Repositories

1

Distributions.jl

A Julia package for probability distributions and associated functions.
Julia
1,073
star
2

GLM.jl

Generalized linear models in Julia
Julia
574
star
3

StatsBase.jl

Basic statistics for Julia
Julia
565
star
4

Distances.jl

A Julia package for evaluating distances (metrics) between vectors.
Julia
410
star
5

MixedModels.jl

A Julia package for fitting (statistical) mixed-effects models
Julia
402
star
6

MultivariateStats.jl

A Julia package for multivariate statistics and data analysis (e.g. dimension reduction)
Julia
370
star
7

Clustering.jl

A Julia package for data clustering
Julia
343
star
8

TimeSeries.jl

Time series toolkit for Julia
Julia
342
star
9

HypothesisTests.jl

Hypothesis tests for Julia
Julia
287
star
10

StatsModels.jl

Specifying, fitting, and evaluating statistical models in Julia
Julia
245
star
11

StatsFuns.jl

Mathematical functions related to statistics.
Julia
224
star
12

MLBase.jl

A set of functions to support the development of machine learning algorithms
Julia
186
star
13

Klara.jl

MCMC inference in Julia
Julia
168
star
14

RDatasets.jl

Julia package for loading many of the data sets available in R
R
160
star
15

Lasso.jl

Lasso/Elastic Net linear and generalized linear models
Julia
141
star
16

StatsKit.jl

Convenience meta-package to load essential packages for statistics
Julia
136
star
17

PDMats.jl

Uniform Interface for positive definite matrices of various structures
Julia
103
star
18

Loess.jl

Local regression, so smooooth!
Julia
99
star
19

GLMNet.jl

Julia wrapper for fitting Lasso/ElasticNet GLM models using glmnet
Julia
96
star
20

NMF.jl

A Julia package for non-negative matrix factorization
Julia
89
star
21

Survival.jl

Survival analysis in Julia
Julia
73
star
22

LogExpFunctions.jl

Julia package for various special functions based on `log` and `exp`.
Julia
73
star
23

Statistics.jl

The Statistics stdlib that ships with Julia.
Julia
69
star
24

TimeModels.jl

Modeling time series in Julia
Julia
57
star
25

DataArrays.jl

DEPRECATED: Data structures that allow missing values
Julia
53
star
26

PGM.jl

A Julia framework for probabilistic graphical models.
Julia
52
star
27

ConjugatePriors.jl

A Julia package to support conjugate prior distributions.
Julia
46
star
28

SVM.jl

SVM's for Julia
Julia
41
star
29

Roadmap.jl

A centralized location for planning the direction of JuliaStats
35
star
30

NullableArrays.jl

DEPRECATED Prototype of the new JuliaStats NullableArrays package
Julia
35
star
31

Distance.jl

Julia module for Distance evaluation
Julia
27
star
32

DimensionalityReduction.jl

Deprecated in favor of MultivariateStats.jl
Julia
27
star
33

Rmath-julia

The Rmath library from R
C
25
star
34

RegERMs.jl

DEPRECATED: Regularised Empirical Risk Minimisation Framework (SVMs, LogReg, Linear Regression) in Julia
Julia
17
star
35

StatsAPI.jl

A statistics-focused namespace for packages to share functions
Julia
17
star
36

Rmath.jl

Archive of functions that emulate R's d-p-q-r functions for probability distributions
Julia
16
star
37

JuliaStats.github.io

The home page of JuliaStats
CSS
11
star
38

NullableStats.jl

DEPRECATED: Statistical functionality for NullableArrays
Julia
4
star
39

RmathBuilder

Builder repository for rmath-julia
Julia
3
star
40

RmathDist.jl

Julia interface to Rmath distribution functions
Julia
3
star