GithubHelp home page GithubHelp logo

rawls238 / kerneldensity.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juliastats/kerneldensity.jl

0.0 3.0 0.0 358 KB

Kernel density estimators for julia

License: Other

Julia 100.00%

kerneldensity.jl's Introduction

KernelDensity.jl

Build Status KernelDensity KernelDensity

Kernel density estimators for julia.

Usage

Univariate

The main accessor function is kde:

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.

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::Range)

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::Range, dist::Distribution)

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

kde((xdata, ydata))

or a matrix with two columns

kde(datamatrix)

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

Interpolation

The KDE objects are stored as gridded density values, with attached coordinates. These are typically sufficient for plotting (see below), but intermediate values can be interpolated using the Grid.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 intermediate InterpGrid object:

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

InterpKDE can also take additional arguments specifying the BoundaryCondition (default=BCnan) and InterpType (default= InterpQuadratic).

Plotting

The Winston.jl and PyPlot.jl plotting packages are currently supported. See the ijulia notebooks:

We plan to include support for other plotting packages: please file an issue if your favourite one is not yet available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.