Running Average Simulator
The learner runs many independent sample paths of a running mean (or relative frequency, or centred sum) against n, plays the paths forward, drags an inspection line and an epsilon band, and reads off how many paths are outside the band, the run-to-run spread versus sigma/sqrt(n), and Chebyshev or required-n figures. Covers the law of large numbers, Monte Carlo error and laws with no mean (Cauchy, zeta) that never settle.
Used in: Introduction to Probability Theory, Introduction to Statistics
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | from the view | Card title. |
| experiment | string | "coin" ("distribution" when `distribution` is given) | What one trial is: coin (x = 1 with prob. p), die (x in 1..6), two-dice (d1, d2 and x = d1 + d2), point-in-square ((x, y) uniform in [0,1]^2) or distribution (x drawn from `distribution`). |
| distribution | string | {family, params} | "Normal(0, 1)" | Law of one draw for experiment "distribution": any spec the sampling core accepts ("Exp(rate=1)", "Cauchy(0, 1)", {family: "binomial", params: {n: 30, p: "1/12"}}), plus the local families "zeta" (P(X=k) proportional to k^-s, params {s}) and "signed-zeta". |
| p | number | 0.5 | Success probability of the coin experiment. |
| successLabel | string | "heads" | Name of the outcome x = 1 in the coin experiment (plain text), e.g. "point-up". |
| event | string | null | null | Condition on the trial's variables (x; d1, d2 for two-dice; x, y for point-in-square), e.g. "x == 6", "x >= 9", "d1 == d2", "x^2 + y^2 <= 1". The tracked value becomes its indicator, so the running mean is a relative frequency. |
| transform | string | null | null | Expression g of the trial's variables, e.g. "x^2" or "exp(x)"; the running mean then estimates E[g]. Ignored when `event` is set. |
| quantityLabel | string | from the view | Y-axis label for the plotted statistic (plain text with $...$ TeX). |
| target | number | null | computed | Value the running mean should approach. Default: the exact mean of the tracked value when it can be computed (numerically for point-in-square and transformed continuous laws, marked approx.). Not shown when the mean does not exist. |
| targetLabel | string | "p" for events, "\\mu" otherwise | TeX symbol for the target, e.g. "\\theta", "P(\\text{six})". |
| compareTarget | number | null | null | A competing (wrong) model's value, drawn as a second dashed line in the running-mean view. |
| compareLabel | string | "competing model" | Legend text for `compareTarget`. |
| normalizer | string | "n" | Initial view: n (running mean S_n/n), none (centred sum S_n - n mu), sqrt ((S_n - n mu)/sqrt n), lil ((S_n - n mu)/sqrt(2 n log log n)). |
| normalizers | string[] | [] | Views offered in a picker (values as for `normalizer`); empty or one entry hides the picker. |
| maxN | number | 1000 | Horizon: number of trials per path (10 to 1,000,000; paths x maxN is capped at 4,000,000). |
| paths | number | 20 | Number of independent paths (1 to 1000; at most 60 are drawn, all are used in the readouts). |
| seed | number | string | 1 | Seed of the reproducible random stream; New sample moves to the next stream. |
| epsilon | number | null | 0.1 (or `margin`) | Half-width of the band around the target in the running-mean view, with a slider; null hides the band. |
| showEpsilonSlider | boolean | true | Show the epsilon slider. |
| deviationBand | number | 10 | Half-width c of the band around 0 in the centred-sum view (none). |
| showSEBand | boolean | false | Draw the envelope target +- z sigma/sqrt(n) (scaled to the current view). |
| confidence | number | 0.95 | Level that sets z for the SE envelope and the required-n formula. |
| showChebyshev | boolean | false | Show the Chebyshev bound sigma^2/(n epsilon^2) next to the observed fraction outside the band (and as a checkpoint column). |
| showHistogram | boolean | false | Histogram of the plotted statistic across paths at the inspected n, with its normal approximation (and the one-draw density for Cauchy laws). |
| showErrorPlot | boolean | false | Log-log plot of the root-mean-square error over paths against n, with the sigma/sqrt(n) reference line. |
| showDraws | boolean | false | Point-in-square only: scatter of path 1's draws up to the inspected n, coloured by the event. |
| checkpoints | number[] | null | null | Values of n marked on the plot and tabulated (mean, SD across paths, theory SD, fraction outside the band). |
| inspectN | number | null | maxN (the required n when `margin` is set) | Initial position of the draggable inspect line (readouts and histogram use this n). |
| margin | number | null | null | Target margin of error E: shows required n = ceil((z sigma/E)^2) as a vertical line and readout, and sets the band to +-E unless `epsilon` is given. |
| planningSd | number | null | null | Planning sd for `margin` (e.g. 0.5, the worst case for a proportion). Default: the pilot estimate if `pilotN` is set, else the model sd. |
| pilotN | number | null | null | Estimate the planning sd S_0 from the first pilotN draws of path 1. |
| exactHitValue | number | null | null | Mark the n at which a path's running mean equals this value exactly, and count such paths at the inspected n (with the exact probability for a coin). |
| logX | boolean | true when maxN >= 100 | Logarithmic n axis (learner can toggle). |
| yRange | [number, number] | null | auto | Fixed y range for the running-mean view. |
| controls | string[] | all controls shown | Ids of the hideable readouts and legends to show (see the controls registry: readout.sd, readout.theory-sd, label.sample-mean, legend.normal-approximation, legend.law-density); core ones always show. Absent = everything. Fitted per page by tooling, not by hand. |
PreviousNext