Density Estimate Explorer

A histogram the learner regroups: drag the class width (and first cutpoint) and watch too-wide classes hide the shape and too-narrow ones turn it into spikes, switch between frequency, relative-frequency and density scales, read the linked frequency table, merge classes, or overlay a kernel density estimate built as a sum of bumps with a bandwidth slider.

Used in: Introduction to Statistics

Props

PropTypeDefaultDescription
titlestringHistogram (or 'Kernel density estimate' / 'Histogram and kernel density estimate')Card title.
datanumber[]the 20 egg weights of Lecture 2 (54.4 ... 62.2)The raw sample (up to 5000 values). Classes are counted from it, so the learner can regroup it with the sliders.
countsnumber[] | number[][](none)Class frequencies when there is no raw data (one list per histogram, up to 6, drawn side by side on a shared axis). Needs `cutpoints` (one more than the counts) or `start` + `width`. Sliders and the KDE are unavailable; tapping cutpoints still merges classes.
labelsstring | string[](none; scale panels are captioned by their scale)Caption above each histogram (one per `counts` list, or per scale panel); $...$ TeX allowed.
truthstring | {family, params}(none)Population to simulate the sample from when `data` is absent (any distribution spec of the sampling core, e.g. 'N(0,1)' or a mixture). Adds a 'New sample' button and the true density (dashed) on the density scale.
nnumber100Sample size drawn from `truth`.
seednumber1Seed of the first simulated sample.
cutpointsnumber[](none)Explicit class boundaries, increasing (unequal widths allowed). Moving a slider replaces them by equal-width classes starting at the first cutpoint.
startnumberthe first cutpoint, else a multiple of the width at or below the minimumOrigin of the equal-width grid start + k * width; the first class begins at the largest grid point at (closed left) or below (closed right) the smallest value.
widthnumberfrom the cutpoints, else a Sturges-sized nice widthClass width of the equal-width grid.
widthSlider[min, max] | [min, max, step] | booleantrue (automatic range)Class-width slider; false hides it. Ignored for `counts`.
startSlider[min, max] | [min, max, step] | booleanfalseSlider moving the first cutpoint / grid origin (true = one width either side).
closedstringleft'left': classes [a, b) written 'a - under b' (cutpoint grouping); 'right': classes (a, b].
scalestringthe first of `scales`Starting vertical axis: 'frequency', 'relative' (relative frequency) or 'density' (relative frequency / width).
scalesstring[][frequency, relative, density]Scales the learner can switch among (one entry hides the switch); with scaleLayout 'panels', one histogram per scale.
scaleLayoutstringswitch'switch': one histogram with a scale toggle; 'panels': the same classes drawn once per entry of `scales`, side by side (same shape, different axis).
showCountsbooleanfalsePrint each bar's height above it (learner can toggle).
showTablebooleanfalseFrequency table beside the bars (under them on narrow screens), rows linked to the bars on hover.
tableColumnsstring[][frequency, relative]Table columns after 'Class': frequency, relative, cumulative, cumulative-relative, density.
showTotalbooleanfalseAdd a Total row (n and the sum of the relative frequencies) to the table.
editableCutpointsbooleanfalseShow the interior cutpoints as chips; tapping one removes it and merges its two classes (tap again to restore).
removeCutpointsnumber[][]Interior cutpoints removed at the start (classes already merged).
showBoxplotbooleanfalseBoxplot of the raw data under the histogram, on the same axis (halves quartiles, 1.5 IQR fences).
estimatorstringhistogram'histogram', 'kde' (kernel density estimate, a sum of bumps) or 'both' (density histogram with the KDE on top). The KDE needs raw data.
estimatorsstring[][estimator]Estimators the learner can switch among (two or more show a toggle).
kernelstringgaussianKDE kernel: gaussian, epanechnikov, uniform, triangular, biweight.
kernelsstring[][kernel]Kernels offered in a dropdown (two or more show it).
bandwidthnumberSilverman's rule of thumbStarting KDE bandwidth h.
bandwidthSlider[min, max] | [min, max, step]rule of thumb / 8 to x 4Range of the bandwidth slider.
showBumpsbooleanfalseDraw each observation's scaled kernel K_h(x - x_i)/n under the KDE (up to 60 observations).
showTruthbooleantrueDraw the `truth` density (dashed) on the density scale.
xLabelstringValue (Egg weight (grams) for the default data)Horizontal axis title; $...$ TeX allowed.
xDomain[min, max]the classes (and the KDE's reach)Fixed horizontal range.
yMaxnumberautomaticFixed top of the vertical axis (e.g. to match a printed figure).
controlsstring[]all controls shownIds of the hideable controls to show (see the controls registry: scale.density, legend.truth, readout.rule-of-thumb); core controls always show. Omit to show everything. Fitted per page by component_scopes.py, not by hand. The starting `scale` always stays offered.