nonparametric kernel smoothing
npm install kernel-smooth[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Dependencies][dependencies-image]][dependencies-url]
> nonparametric kernel smoothing for JavaScript
Via npm:
```
npm install kernel-smooth
Require as follows:
``
var kernel = require('kernel-smooth');
Given input data xs, a kernel function and a bandwidth (if not supplied,x
a default value of 0.5 is used), this function returns a basic kernel density
estimator: a function of one variable, , which when invoked returns thex
kernel density estimate for . The returned function can also be called with ax
vector supplied as an argument for . In this case, the density is evaluated
is for each element of the vector and the vector of density estimates
is returned.
Given input predictors xs and observed responses ys, a kernel functionx
and a bandwidth (if not supplied, a default value of 0.5 is used),
this function returns the Nadaraya & Watson kernel regression estimator:
a function of one variable, , which when invoked returns they
estimate for . The returned function can also be called with ax
vector supplied as an argument for . In this case, predictions are generated
for each element of the vector and the vector of predictions
is returned.
Similar to .regression(), except that Xs should be a 2d array containing multiple predictors. Each element of Xs should has to be an array of length p, with p denoting the number of predictors. The returned estimator generates a prediction for a new data point x = (x_1, ..., x_p). If a 2d array is supplied instead, predictions are generated for multiple data points at once, where each row (= element of the outer array) is assumed to be a datum x = (x_1, ..., x_p).
For the kernel parameter in above functions, you should supply a univariate function K(x) which satisfies K(x) >= 0, integrates to one, has zero mean and unit variance..fun` object for a list of already implemented kernel functions.
See the functions in the exported
#### .gaussian(x)
Gaussian kernel, pdf of standard normal distribution.
#### .boxcar(x)
Boxcar kernel, defined as 0.5 if |x| <= 1 and 0 otherwise.
#### .epanechnikov(x)
Epanechnikov kernel. Equal to zero if |x| > 1. Otherwise defined as
0.75 * (1 - x^2).
#### .tricube(x)
Tricube kernel function. Equal to zero if |x| > 1 and otherwise equal to
(70/81) * (1-|x|^3)^3.
MIT © Philipp Burckhardt
[npm-url]: https://npmjs.org/package/kernel-smooth
[npm-image]: https://badge.fury.io/js/kernel-smooth.svg
[travis-url]: https://travis-ci.org/Planeshifter/kernel-smooth
[travis-image]: https://travis-ci.org/Planeshifter/kernel-smooth.svg?branch=master
[coveralls-image]: https://img.shields.io/coveralls/Planeshifter/kernel-smooth/master.svg
[coveralls-url]: https://coveralls.io/r/Planeshifter/kernel-smooth?branch=master
[dependencies-image]: https://david-dm.org/Planeshifter/kernel-smooth.svg?theme=shields.io
[dependencies-url]: https://david-dm.org/Planeshifter/kernel-smooth