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
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Histogram (or 'Kernel density estimate' / 'Histogram and kernel density estimate') | Card title. |
| data | number[] | 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. |
| counts | number[] | 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. |
| labels | string | string[] | (none; scale panels are captioned by their scale) | Caption above each histogram (one per `counts` list, or per scale panel); $...$ TeX allowed. |
| truth | string | {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. |
| n | number | 100 | Sample size drawn from `truth`. |
| seed | number | 1 | Seed of the first simulated sample. |
| cutpoints | number[] | (none) | Explicit class boundaries, increasing (unequal widths allowed). Moving a slider replaces them by equal-width classes starting at the first cutpoint. |
| start | number | the first cutpoint, else a multiple of the width at or below the minimum | Origin 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. |
| width | number | from the cutpoints, else a Sturges-sized nice width | Class width of the equal-width grid. |
| widthSlider | [min, max] | [min, max, step] | boolean | true (automatic range) | Class-width slider; false hides it. Ignored for `counts`. |
| startSlider | [min, max] | [min, max, step] | boolean | false | Slider moving the first cutpoint / grid origin (true = one width either side). |
| closed | string | left | 'left': classes [a, b) written 'a - under b' (cutpoint grouping); 'right': classes (a, b]. |
| scale | string | the first of `scales` | Starting vertical axis: 'frequency', 'relative' (relative frequency) or 'density' (relative frequency / width). |
| scales | string[] | [frequency, relative, density] | Scales the learner can switch among (one entry hides the switch); with scaleLayout 'panels', one histogram per scale. |
| scaleLayout | string | switch | 'switch': one histogram with a scale toggle; 'panels': the same classes drawn once per entry of `scales`, side by side (same shape, different axis). |
| showCounts | boolean | false | Print each bar's height above it (learner can toggle). |
| showTable | boolean | false | Frequency table beside the bars (under them on narrow screens), rows linked to the bars on hover. |
| tableColumns | string[] | [frequency, relative] | Table columns after 'Class': frequency, relative, cumulative, cumulative-relative, density. |
| showTotal | boolean | false | Add a Total row (n and the sum of the relative frequencies) to the table. |
| editableCutpoints | boolean | false | Show the interior cutpoints as chips; tapping one removes it and merges its two classes (tap again to restore). |
| removeCutpoints | number[] | [] | Interior cutpoints removed at the start (classes already merged). |
| showBoxplot | boolean | false | Boxplot of the raw data under the histogram, on the same axis (halves quartiles, 1.5 IQR fences). |
| estimator | string | histogram | 'histogram', 'kde' (kernel density estimate, a sum of bumps) or 'both' (density histogram with the KDE on top). The KDE needs raw data. |
| estimators | string[] | [estimator] | Estimators the learner can switch among (two or more show a toggle). |
| kernel | string | gaussian | KDE kernel: gaussian, epanechnikov, uniform, triangular, biweight. |
| kernels | string[] | [kernel] | Kernels offered in a dropdown (two or more show it). |
| bandwidth | number | Silverman's rule of thumb | Starting KDE bandwidth h. |
| bandwidthSlider | [min, max] | [min, max, step] | rule of thumb / 8 to x 4 | Range of the bandwidth slider. |
| showBumps | boolean | false | Draw each observation's scaled kernel K_h(x - x_i)/n under the KDE (up to 60 observations). |
| showTruth | boolean | true | Draw the `truth` density (dashed) on the density scale. |
| xLabel | string | Value (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. |
| yMax | number | automatic | Fixed top of the vertical axis (e.g. to match a printed figure). |
| controls | string[] | all controls shown | Ids 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. |