Bayesian Update Explorer
The learner moves prior hyperparameters (or switches the prior family, or types a prior density) and edits the data, and watches prior, rescaled likelihood and posterior on one axis: the conjugate update and the posterior mean as a weighted average, a numerically normalised posterior with the marginal likelihood when no closed form exists, a draggable cutoff for P(theta > c | data), and a sequential mode that feeds observations one at a time, in any order, with each posterior becoming the next prior.
Used in: Introduction to Probability Theory
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Prior × likelihood ∝ posterior" (sequential: "Sequential Bayesian updating") | Card title. |
| mode | string | "update" | update: all the data at once. sequential: observations are added one at a time (Back / Next / Play / Shuffle order); the posterior after each one is the prior for the next. |
| prior | object | string | per likelihood (binomial: Beta(2, 2); Poisson/exponential: Gamma(2, 1); normal: N(0, 2^2); uniform: Gamma(2, 2)) | A family spec {family, params} or a string such as "Beta(2,2)" (families: beta {alpha, beta}, gamma {shape, rate}, exponential {rate}, normal {mean, sd}, cauchy {location, scale}, uniform {a, b}); or a custom density {expr, support} such as {expr: "2*x", support: [0, 1]} (variable x, theta or the symbol; a leading "y =" is ignored; normalised numerically). |
| priorSupport | [number, number] | [0, 1] | Support of a custom prior given as a bare expression string. |
| likelihood | string | object | "binomial" | Model for the data given the parameter: binomial, bernoulli, poisson, exponential (rate), normal (mean, known sigma; "N(theta, 1)" reads sigma^2 = 1) or uniform (Uniform(0, theta)). Or a custom density of ONE observation y: {expr: "2*y/x^2", min: "y", max: ...}, where min/max are expressions in y bounding the parameter values with positive density. |
| model | string | object | (none) | Alias of likelihood. |
| sigma | number | 1 | Known standard deviation of the normal likelihood. |
| data | number[] | object | string | per likelihood (binomial: 7 of 10) | Binomial/bernoulli: {successes, n} (or {successes, failures}, "7/10") or a 0/1 list. Poisson: a list of counts or {count, exposure} (total events over a window of length t). Others: a list of observations. The learner can edit it. |
| observed | number[] | object | string | (none) | Alias of data. |
| symbol | string | per likelihood: p, \lambda, \mu, \theta | TeX name of the parameter on the axis and in the readouts; also accepted as the variable in custom expressions. |
| xRange | [number, number] | automatic | Visible parameter window. Default [0, 1] for a probability, otherwise from the prior and posterior quantiles. |
| parameters | {name, min?, max?, step?, initial?}[] | [] | Slider ranges / initial values for prior hyperparameters by name (alpha, beta, shape, rate, mean, sd, location, scale, a, b; aliases such as tau for sd, m0 for mean). |
| cutoff | number | null | null | Turns on the tail readout: a draggable cutoff c with P(theta > c | data) shaded and reported (and the prior P(theta > c)). |
| showConjugateUpdate | boolean | true | Show the conjugate rule with its numbers and the posterior mean as a weighted average of prior mean and data estimate (or, without conjugacy, the normalising integral). |
| showLikelihood | boolean | true | Initially show the likelihood (rescaled to area 1 over the window). The learner can toggle it. |
| showPrior | boolean | true | Initially show the prior. The learner can toggle it. |
| showMeans | boolean | false | Initially mark the prior mean, the MLE and the posterior mean. |
| allowPriorChange | boolean | true | Show the prior-family picker (beta/uniform on [0,1]; gamma/exponential/uniform on (0, inf); normal/Cauchy/uniform on the line). |
| editable | boolean | true | Show the data controls. |
| step | number | 0 | Sequential mode: number of observations already used at start. |
| seed | number | string | 1 | Seed for the Shuffle order button. |
| gridPoints | number | 4000 | Grid cells for the numerical normalisation when the pair is not conjugate. |
| controls | string[] | all controls shown | Ids of the hideable toggles, readouts and panels to show (see the controls registry: toggle.means, readout.mle, readout.means, readout.sd, readout.mode, readout.credible-interval, readout.evidence, toggle.tail, panel.conjugate, readout.weighted-average, panel.normalisation). Core controls always show. Absent = everything. Fitted per page by tooling, not by hand. |
PreviousNext