Skip to content

silvermanBandwidth

Silverman’s rule-of-thumb bandwidth for a gaussian kernel density estimate: 0.9 · min(σ, IQR / 1.34) · n^(-1/5). When one of the two spreads is zero the other is used; when the values don’t vary at all (including a single value) the spread falls back to a tenth of their magnitude, or 1 for zeros. Non-finite values are ignored. Returns NaN when there are no values.

Silverman’s rule of thumb, 0.9 · min(σ, IQR / 1.34) · n^(-1/5): the default kernelDensity bandwidth. Taking the smaller of the standard deviation and the scaled interquartile range keeps one outlier (the second call) from oversmoothing the rest. Values that don’t vary fall back to a tenth of their magnitude.

import {silvermanBandwidth} from "@d3plus/math";

silvermanBandwidth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
silvermanBandwidth([1, 2, 3, 4, 5, 6, 7, 8, 9, 1000]);
silvermanBandwidth([5, 5, 5, 5]);
silvermanBandwidth([42]);

Parameters

import {silvermanBandwidth} from "@d3plus/math";
valuesrequiredArray.<number>

The observations.