Formula: Silverman & Scott KDE Bandwidth Formula
- sampleStdDevS: Sample Std Dev S (SD s)
- interquartileRangeIqr: Interquartile Range (IQR)
- sampleSizeN: Sample Size N (n)
Compute Silverman’s robust KDE bandwidth h and Scott’s normal-reference bandwidth.
If the data look roughly bell shaped, the two will be close and either is fine. If they differ a lot, Silverman's is usually the safer default because it uses the smaller of the two spread estimates and a lower constant, which protects against oversmoothing. Scott's suits data you are confident are near normal. Plot both and compare.
Because the IQR term is already the smaller spread. With an IQR of 18, IQR/1.34 is 13.433. Any standard deviation above that leaves the minimum unchanged, so Silverman's h stays at 4.007 whether s is 14.2 or 21. Scott's rule has no such cap, which is why it rises to 7.378 in the higher case.
Neither is wrong. The IQR of a standard normal distribution is about 1.349, and Silverman's original rule rounds it to 1.34. Some software uses 1.349. The difference changes the robust spread by less than one percent, so h barely moves. The calculator uses 1.34, matching the formula printed on the page.
For a smooth density and a Gaussian kernel, the bandwidth that balances bias against variance shrinks in proportion to n to the power negative one fifth. Wider kernels add bias by blurring real features, narrower ones add variance from noise. That trade-off gives the slow rate, which is why 250 observations still produce a fairly wide h of 4.007.
The constants 0.9 and 1.06 are derived for a Gaussian kernel, and the calculator assumes one. Other kernels, such as the Epanechnikov, need a different scale factor to give an equivalent amount of smoothing. Many packages handle that conversion internally when you pass a Gaussian-equivalent bandwidth. Check the documentation of the tool you are using.
Not directly. The exponent of negative one fifth applies to one dimension. In d dimensions the normal reference exponent becomes negative one over d plus four, and the spread is usually a covariance matrix rather than one standard deviation. For two variables, use software that estimates a bandwidth matrix, or apply the rule to each variable separately as a rough start.
Both control smoothing, but they are not the same number. A kernel bandwidth is the standard deviation of each Gaussian bump, while a bin width is the full width of a bar. A histogram with bins equal to h will look rougher than the kernel estimate. There are separate rules for bins, such as Scott's and Freedman Diaconis.
Usually because s or the IQR was entered in the wrong units or from the wrong statistic, such as a standard error. Sample size alone shrinks h slowly; going from 100 to 250 observations only moves Silverman's h from 4.813 to 4.007. A bandwidth far smaller than you expect almost always traces back to a spread figure that is too small.
Only if the detail is real. Halving h will always produce more bumps, and some will be noise. A useful test is to resample the data or split it in half and estimate each part. Features that appear in both halves at the same bandwidth are probably genuine. Features that come and go are artefacts of a bandwidth set too low.
No. It needs only three summaries: the sample standard deviation, the interquartile range and the number of observations. That makes it quick to use from a report or a printed table. It also means it cannot detect skew, gaps or multiple peaks, so look at a plot of the actual data before trusting any rule of thumb.
Not on this page. The standard deviation and IQR must both be above zero, and the sample size a whole number of 2 or more, or the page shows an error instead of a result. Any accepted input therefore gives a positive h. If the page returns an h much smaller than the spread of your data suggests, recheck the figures you typed.
Start with the default numbers: a sample of n = 250, a standard deviation s of 14.2 and an interquartile range of 18. The calculator returns a Silverman bandwidth h of 4.007 as its headline and a Scott bandwidth of 4.989 beneath it. The two rules disagree by almost a full unit, and the reason is visible in the third line, Robust Spread min(s, IQR/1.34), which shows 13.433.
Silverman's version does not simply use s. It divides the IQR by 1.34 to get a second estimate of spread, 18 / 1.34 = 13.433, and keeps whichever is smaller. Here the IQR-based figure wins, so Silverman's rule works from 13.433 while Scott's rule works from the full 14.2. On top of that, Silverman multiplies by 0.9 and Scott by 1.06. Both effects push Silverman's answer lower.
Both bandwidths are in the same units as your data. If the observations are test scores, an h of 4.007 means each data point is spread into a Gaussian bump with a standard deviation of about four points. A larger h gives a smoother curve with fewer bumps. A smaller h follows the data more closely and shows more local detail, including noise.
The engine uses exactly the constants on the page: h_Silverman = 0.9 × min(s, IQR / 1.34) × n^(−1/5) and h_Scott = 1.06 × s × n^(−1/5). Nothing is hidden.
The shared factor is n to the power negative one fifth. For 250 that is about 0.3314. Then 0.9 times 13.433 times 0.3314 gives 4.007, and 1.06 times 14.2 times 0.3314 gives 4.989. The interpretation line shows the Scott figure to four places as 4.9889.
The constants have a reason. For a standard normal distribution the interquartile range is about 1.349 standard deviations, so dividing an IQR by 1.34 turns it into a standard deviation estimate that outliers cannot drag upward. The 1.06 comes from the bandwidth that minimises the integrated squared error when both the data and the kernel are Gaussian; it is the fifth root of four thirds, rounded. The 0.9 is Silverman's deliberate trim below that value, chosen so the rule holds up better when the data are skewed or have more than one peak.
A clean test case: n = 32 makes n^(−1/5) exactly 0.5. With s = 10 and an IQR of 13.4, both spread estimates equal 10, so Silverman gives 4.5 and Scott gives 5.3. The ratio between them, 0.849, is just 0.9 divided by 1.06.
The min() inside Silverman's rule is the part that does real work, and the page's comparison runs show it well.
Drop s to 8.5 while keeping the IQR at 18. Now 8.5 is smaller than 13.433, so the robust spread line reads 8.5 and Silverman's h falls to 2.536. Scott's h falls to 2.986. Both rules now use the same spread and differ only by the constant.
Raise s to 21 instead. Scott's bandwidth climbs to 7.378, because it scales directly with s. Silverman's stays at 4.007, exactly the default, because the IQR is still the smaller of the two spreads and the IQR did not change.
That second case is the one to watch for in practice. A standard deviation far larger than IQR/1.34 usually means heavy tails or a few extreme values. Scott's rule then oversmooths the middle of the distribution, flattening real structure to accommodate the tails. Silverman's rule ignores the tails when choosing the width. If the two bandwidths differ a lot and the robust spread line shows the IQR term, look at the data for outliers before picking one.
The fifth root makes the bandwidth very insensitive to sample size. Keep s at 14.2 and the IQR at 18, and change n from 250 to 100. Silverman's h rises only from 4.007 to 4.813, and Scott's from 4.989 to 5.992. Cutting the sample by more than half widens the bandwidth by about a fifth.
Going the other way, you need 32 times as many observations to halve h. This is the main reason a rule of thumb is usually good enough for a first plot. The answer does not swing around with small changes in n, so an approximate count is fine.
The page needs a whole number of at least 2 for n. At the minimum the bandwidths become very wide: with the default spreads and n = 2, Silverman's h is 10.525 and Scott's is 13.104. With so few points a density estimate says very little anyway; a dot plot or a plain list of values is more honest.
A fractional n such as 25.5 returns an error, which catches pasted averages. Enter the count of observations, not the number of groups or bins.
Software packages use these names inconsistently, which causes real confusion when someone compares a plot from this page with one from code.
In R, the default bandwidth for density() is bw.nrd0, which is the same 0.9 × min(s, IQR/1.34) × n^(−1/5) rule this page calls Silverman's. R's bw.nrd uses 1.06 instead of 0.9 but still takes the minimum of the two spreads, so it is not quite the Scott figure shown here, which uses s alone.
SciPy's gaussian_kde works differently. It multiplies the data's standard deviation by a factor. Its scott option uses a factor of n^(−1/5) with no 1.06, and its silverman option uses (3n/4)^(−1/5), which is about 1.06 × n^(−1/5). So SciPy's silverman is close to this page's Scott, and SciPy's scott always lands between this page's two figures. Neither SciPy option applies the IQR correction.
The practical rule: when you move a bandwidth between tools, move the number, not the name. Copy the h from this page and pass it as an explicit bandwidth, adjusting for how the package scales it.
The fourth result line, Height of One Gaussian Kernel 1/(h√2π), shows 0.1 for the defaults. It is 1 divided by h times the square root of 2π, the height at the centre of a single Gaussian kernel with standard deviation h. With h = 4.007 that comes to about 0.0996, shown rounded to 0.1.
It is not the height of your estimated density. A kernel density estimate averages n kernels, each scaled by 1/n, so a single isolated point contributes only a tiny fraction of that peak. The actual maximum of the curve depends on how tightly the data cluster, which a summary of s, IQR and n cannot tell you.
The line is a handy check on scale. It halves when h doubles. In the n = 32, s = 10 case it reads 0.089 for an h of 4.5, and in the lower comparison run, with s = 8.5, it rises to 0.157 because h falls to 2.536. If you halve the bandwidth by hand to reveal more detail, each kernel gets twice as tall and twice as narrow, and the curve turns spikier in proportion.
Both formulas are normal reference rules. They give the ideal bandwidth if the true distribution is a single bell curve. Real data often are not.
Bimodal data are the main failure. Two separate peaks inflate the standard deviation, and Scott's rule then smooths them into one hump. Silverman's min() and 0.9 help, because the IQR of a bimodal sample is often smaller than 1.34 s, but they do not guarantee the peaks survive. If you suspect several groups, try half the suggested h and see whether a second mode appears and stays.
Strongly skewed data, such as incomes or response times, have a similar problem in the long tail: one bandwidth cannot suit both the dense head and the sparse tail. A log transform before estimating usually works better than any choice of h.
For a final analysis, data-driven selectors such as Sheather and Jones or cross-validation choose h from the shape of the sample itself, at the cost of more computing. Silverman's figure remains a reasonable starting point and a sanity check for whatever they return.
Use the sample standard deviation of the raw observations, in the same units you will plot. Do not use a standard error, which is s divided by the square root of n and would make h far too small.
The IQR is the third quartile minus the first, the full width of the middle half. A semi-interquartile range, half that width, will make the IQR term look artificially small and Silverman's h roughly half what it should be. Different packages compute quartiles slightly differently; the differences are small and rarely move h by more than a few percent.
A standard deviation or IQR of zero, or a negative value, returns an error. Constant data have no spread and no density to estimate, so the page refuses rather than producing a meaningless near-zero bandwidth.
Finally, n is the number of observations used to compute s and the IQR. If you removed outliers before computing the spread, use the reduced count.