Pictures for the Shelf

Charts for statistics

The pictures phase of the statistics package: box plots, histograms with a density over them, density curves with a certified shaded probability, quantile plots, fitted lines with bands, power curves, and a sampling distribution building up.

Box plots by Tukey's hinges

fiveNumbers(values) sorts the data and takes the median of each half (the middle value in both halves when nn is odd). With Q1Q_1 and Q3Q_3 the hinges and IQR=Q3−Q1\mathrm{IQR} = Q_3 - Q_1, the whiskers reach the furthest data inside [Q1−1.5 IQR, Q3+1.5 IQR][Q_1 - 1.5\,\mathrm{IQR},\ Q_3 + 1.5\,\mathrm{IQR}] and the rest are drawn as outliers. boxPlot({ name: values, … }) sets the boxes side by side.

Histograms and densities

histogramFigure(values, { bins, distribution }) draws the counts, or with a distribution the density scale (total area 1) with the curve over it. densityFigure(dist, { shade: [a, b] }) draws the density from the distribution's fast float version and shades P(a≤X≤b)P(a \le X \le b). The curve is estimated; the probability in the notes is the distribution's own prob(a, b), which in @ratmath/stats is a certified interval.

Quantile plots

qqPlot(values, dist) sets the ii-th smallest value against the distribution's quantile at (i−12)/n(i - \tfrac12)/n. Data from that family, after a shift and a scale, fall along a line; the line drawn is the one through the quartiles. A bend at the ends means heavier or lighter tails.

Fits, power and sampling

scatterFit(points, { fit, band }) takes a line as { intercept, slope } or a regression's coefficients, and a band as a function x↦[ℓ,u]x \mapsto [\ell, u]. powerCurve draws the chance a test rejects against the true effect, with the level as a dashed line. samplingBuildUp(values, { steps }) gives frames of a histogram of the first kk values on shared bins and scales, marked simulated: animate them to watch the shape settle.

Try itEdit the code and run it with @ratmath/graphics and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math, and SHOW(svg) draws a picture.
Ctrl/⌘ + Enter runs