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

PropTypeDefaultDescription
titlestring"Prior × likelihood ∝ posterior" (sequential: "Sequential Bayesian updating")Card title.
modestring"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.
priorobject | stringper 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.
likelihoodstring | 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.
modelstring | object(none)Alias of likelihood.
sigmanumber1Known standard deviation of the normal likelihood.
datanumber[] | object | stringper 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.
observednumber[] | object | string(none)Alias of data.
symbolstringper likelihood: p, \lambda, \mu, \thetaTeX name of the parameter on the axis and in the readouts; also accepted as the variable in custom expressions.
xRange[number, number]automaticVisible 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).
cutoffnumber | nullnullTurns on the tail readout: a draggable cutoff c with P(theta > c | data) shaded and reported (and the prior P(theta > c)).
showConjugateUpdatebooleantrueShow 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).
showLikelihoodbooleantrueInitially show the likelihood (rescaled to area 1 over the window). The learner can toggle it.
showPriorbooleantrueInitially show the prior. The learner can toggle it.
showMeansbooleanfalseInitially mark the prior mean, the MLE and the posterior mean.
allowPriorChangebooleantrueShow the prior-family picker (beta/uniform on [0,1]; gamma/exponential/uniform on (0, inf); normal/Cauchy/uniform on the line).
editablebooleantrueShow the data controls.
stepnumber0Sequential mode: number of observations already used at start.
seednumber | string1Seed for the Shuffle order button.
gridPointsnumber4000Grid cells for the numerical normalisation when the pair is not conjugate.
controlsstring[]all controls shownIds 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.