The guide
The bandwidth decides how many humps a density estimate has, and no rule decides the bandwidth
A kernel density estimate replaces each data point with a small bump and adds them up; the width of the bump matters far more than its shape, and a rule of thumb is only a guess.
- 1.1104 Silverman bandwidth of the 12-point example
- 0.9512 efficiency of the Gaussian kernel against Epanechnikov
- 0.02512 factor the best error falls by when n grows a hundredfold
- 3.143 Silverman bandwidth of the two-hump sample, humps of spread 1
- 6 modes in the 12-point example at a bandwidth of 0.15
Read the full guide Fold the guide
Twelve numbers sit on a line. Six of them fall between 1.2 and 2.8, and six between 5.1 and 6.9. Anyone can see two groups. Ask for a smooth curve that shows the same thing and a second question appears at once: how smooth?
That question has no single answer, and the history of density estimation is largely the history of people finding ways to avoid facing it.
From bars to bumps
The idea is older than the name, and the picture is simple. Stack the hills on a line and the places where they pile up are the places where the data are dense.
A histogram cuts the axis into bins and stacks a box on each point that lands in one. The Wikipedia article on histograms is frank about the cost: there is no best number of bins, and different bin sizes can reveal different features of the data. Move the bin edges and the picture changes.
A kernel density estimate trades the boxes for bumps. Each data point gets a small, smooth hill centred on it, every hill has area 1 divided by n, and the hills are added. The Wikipedia article on kernel density estimation writes it as the average over the data of the scaled kernel K((x - x_i) / h) / h. K is a non-negative function, usually symmetric and integrating to 1, and h is a smoothing parameter called the bandwidth.
The 1 / h is easy to drop and fatal to forget. Without it, a kernel stretched to width h would have area h, and the whole estimate would integrate to h, not 1. With the 12-point example and h = 0.5 the area comes out as 0.5000 instead of 1. The page integrates the curve and shows the area, so a missing factor cannot hide.
Why the width matters more than the shape
The Wikipedia article lists the usual kernels: uniform, triangular, biweight, triweight, Epanechnikov and normal. It says the Epanechnikov kernel is optimal in a mean square error sense, and that the loss of efficiency is small for the others. The page makes this concrete. Written for unit variance so that h means the same thing for each, the kernels have efficiency against Epanechnikov of 1 for itself, 0.9859 for the triangular, 0.9512 for the Gaussian and 0.9295 for the uniform. Choose the Gaussian and about 5 percent of the efficiency goes.
The bandwidth is another matter. The same article shows a sample of 100 normal values estimated three times, with bandwidths 0.05, 0.337 and 2: the first a forest of spikes, the last a flat mound, and only the middle one close to the truth. The usual way to formalise this is the mean integrated squared error and its large-sample form, AMISE(h) = R(K) / (n h) + h^4 m2(K)^2 R(f”) / 4. The first term falls as h grows, because more smoothing averages away noise. The second rises, because more smoothing blurs real structure. The best h balances them.
That balance sits at a bandwidth of order n to the power minus one fifth, and it gives an error of order n to the power minus four fifths. The article notes that no non-parametric estimator can beat that rate under weak assumptions. A hundredfold increase in n therefore shrinks the best error by only 100 to the power minus 0.8, or 0.02512. A simulation card on the page draws seeded standard normal samples of 50, 200, 800 and 3,200 values and finds a slope of minus 0.75, close to the theory’s minus 0.8 and a reminder that the theory is asymptotic.
What a rule of thumb assumes
The optimal bandwidth depends on the unknown density, through its second derivative, so a rule must guess. If the density is Gaussian and the kernel is Gaussian, the best bandwidth is (4 s^5 / (3 n)) to the power one fifth, which is about 1.06 s n^(-1/5). The constant is (4/3)^(1/5), 1.05922. The article then describes a variant that lowers the factor to 0.9 and takes the smaller of the standard deviation and the interquartile range divided by 1.34. It calls this Silverman’s rule of thumb, and warns that it can be widely inaccurate when the density is far from normal.
Use the 12-point example. The standard deviation is 2.0280 with the divisor N - 1, which is Bessel’s correction, and the interquartile range is 3.3750 by linear interpolation between order statistics. The normal rule gives 1.3069. Silverman’s rule takes the smaller of 2.0280 and 3.3750 / 1.34 = 2.5187, so the standard deviation wins, and 0.9 x 2.0280 x 12^(-1/5) is 1.1104. The interquartile route would have given 1.3790. Using the variance instead of the standard deviation is a common slip, and it would give a nonsense width in the wrong units.
The rule was built for a roughly normal sample, and the 12 numbers are not one. They are two tight groups. The article shows the same failure on a bimodal mixture of two Gaussians sampled at 200 points, where the rule-of-thumb estimate is significantly oversmoothed. The page loads such a sample: 200 seeded values, half from a hump centred at minus 10 and half at 10, each of spread 1. The overall standard deviation is 10.077, so Silverman’s rule returns 3.143, wider than the humps it is meant to resolve.
Modes are a product of the bandwidth
Count the humps. At the Silverman bandwidth of 1.1104 the 12-point estimate has 2 modes, one near each group. At 2.5 it has 1 mode. At 0.15 it has 6 modes, because each little cluster of close points gets its own bump. The page scans 70 bandwidths from 0.04 s to 2 s and plots the count, so the staircase is visible: many modes at small h, then fewer, then a plateau at 2, then one.
A mode is a local maximum of the estimate, and the Wikipedia article on multimodal distributions says a bimodal distribution commonly arises as a mixture of two unimodal ones. That is a statement about a population. A mode of the estimate is a statement about a sample and a bandwidth together, and the two must not be confused. Reading a hump as a feature of the world is exactly what the page cannot license.
A second trap hides in the grid. The page evaluates the estimate on a fixed number of points and counts the modes there, so a bandwidth narrower than a couple of grid steps would be sampled too coarsely to trust. The page warns when that happens, and the area check is the other alarm: a curve that no longer integrates to 1 has been mishandled somewhere.
Read the estimate itself with care too. At x = 2.5 the Gaussian estimate at the Silverman bandwidth is 0.16136, and at the valley x = 4 it is 0.10686. Those are densities, not probabilities. They are heights of a curve whose area is 1, and they depend on the units of x.
What this page cannot tell you
The page does not do multivariate or adaptive estimation, bandwidth selection by cross-validation or plug-in methods beyond naming them, boundary corrections, or any inference from the shape of the curve. A histogram drawn beside the curve takes the larger of two bar counts, the one from the Freedman-Diaconis bin width, twice the interquartile range over the cube root of n, and the square root of n, and its only job is comparison.
The scan and the simulation run in a web worker so the page stays responsive, and large whole numbers are grouped by the browser’s own number formatting. Normal values for the simulation come from the Box-Muller transform applied to a seeded generator, so a run repeats exactly. None of that changes the statistics.
The kernel itself is only a weighting. The Wikipedia article on kernels asks for two properties, that the function integrates to 1 and is symmetric about zero, and every kernel here has both. Everything that makes one estimate differ from another, once the kernel is fixed, is the width of the hill.
Choose the bandwidth the way you would choose a magnification: try several, say which you used, and do not call the picture the truth.
Sources
Every source consulted for this guide. Links checked November 12, 2026.
- Kernel density estimation Wikipedia
- Kernel (statistics) Wikipedia
- Histogram Wikipedia
- Multimodal distribution Wikipedia
- Interquartile range Wikipedia
- Freedman-Diaconis rule Wikipedia
- Bessel's correction Wikipedia
- Standard deviation Wikipedia
- Box-Muller transform Wikipedia
- Web Workers API MDN Web Docs
- Intl.NumberFormat MDN Web Docs