@data-ui/histogram
Version:
React + d3 library for creating histograms
22 lines (18 loc) • 561 B
JavaScript
;
exports.__esModule = true;
exports.default = kernelEpanechnikov;
/* eslint no-magic-numbers: 0 */
/*
* Returns an Epanechnikov (parabolic) kernel function which takes a
* free smoothing parameter as input.
* code from https://gist.github.com/mbostock/4341954
* kernel info https://en.wikipedia.org/wiki/Kernel_(statistics)
*/
function kernelEpanechnikov(smoothing) {
if (smoothing === void 0) {
smoothing = 5;
}
return function (val) {
return Math.abs(val / smoothing) <= 1 ? 0.75 * ((1 - val * val) / smoothing) : 0;
};
}