@data-ui/histogram
Version:
React + d3 library for creating histograms
17 lines (15 loc) • 495 B
JavaScript
/* 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)
*/
export default 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;
};
}