Joint density slicer

A joint density of (X, Y) as a heat map or contours with its marginals on the axes. The learner drags a slice X = x0 (or Y = y0) and sees the renormalised slice, the conditional density, with its mean and spread; optional event shading with its probability, the conditional-mean curve, and a draggable predictor line compared with E[Y | X].

Used in: Introduction to Probability Theory

Props

PropTypeDefaultDescription
titlestring"Joint density and a conditional slice"Title bar text.
jointDensitystring"bivariate-normal"The joint density: "bivariate-normal" (uses rho, sdX, sdY, muX, muY) or an expression f(x, y) in x, y and any slider parameters, e.g. "exp(-y)", "2", "4xy", "6 exp(-2x - 3y)", "1/x". Operators + - * / ^, implicit multiplication, sqrt exp log abs min max, pi, e. Negative values count as 0.
supportstring(none: wherever the expression is positive)Support of the density as inequalities joined by commas or 'and', e.g. "0 < x < y", "0 <= x <= y <= 1", "x > 0, y > 0". The density is 0 outside it, and its edge is drawn.
rhonumber0.6 for bivariate-normalCorrelation of the bivariate normal (strictly between -1 and 1); the initial value of the rho slider.
sdXnumber1SD of X (bivariate normal).
sdYnumber1SD of Y (bivariate normal).
muXnumber0Mean of X (bivariate normal).
muYnumber0Mean of Y (bivariate normal).
parameters{name, min, max, step?, initial?, label?, description?}[][{"name": "rho"}] for bivariate-normal, [] otherwiseSliders. For bivariate-normal the names rho, sdX, sdY, muX, muY are known (ranges default sensibly and initial values come from the props above); for an expression, any other name used in jointDensity / support / region. [] hides all sliders.
xRange[number, number]automatic (central ~99.6% of each marginal)Visible x window.
yRange[number, number]automaticVisible y window.
viewstring"both" for bivariate-normal, "heatmap" otherwiseInitial display of the joint density: heatmap, contours or both (the learner can switch).
conditionOnstring"x"Which variable is conditioned on initially: "x" (vertical slice, law of Y given X = x0) or "y" (horizontal slice, law of X given Y = y0).
slicenumbermuX + sdX for bivariate-normal, else E[X] (or E[Y])Initial slice position x0 (or y0); the learner drags it.
showConditionTogglebooleantrueShow the Given X / Given Y switch.
showMarginalsbooleantrueInitially show the marginal densities f_X along the top and f_Y along the right edge (learner toggle).
showConditionalMeanbooleanfalseInitially draw the conditional-mean curve E[Y | X = x] (the regression line for a bivariate normal) (learner toggle).
showConditionalSpreadbooleanfalseInitially draw E[Y | X = x] plus and minus one conditional SD (learner toggle).
showSlicebooleantrueIn the conditional panel, also draw the raw slice f(x0, y) dashed, so the learner sees that the conditional density is that slice divided by f_X(x0).
compareMarginalbooleanfalseInitially overlay the marginal of the other variable on the conditional panel (equal for every slice = independence) (learner toggle).
regionstring(none)Event A as inequalities, e.g. "x + y <= 1", "x < y", "0.2 < x <= 0.7, 0.3 < y <= 0.5". A is shaded and P((X, Y) in A) is shown.
conditionalInterval[number | null, number | null](none)[a, b] for a conditional probability P(a < Y < b | X = x0) (or of X given Y = y0); null means unbounded, e.g. [3, null] for P(Y > 3 | X = x0). Shaded in the conditional panel.
showPredictorbooleanfalseAdd a draggable straight-line predictor g and compare its mean squared error E[(Y - g(X))^2] with the minimum E[Var(Y | X)] achieved by E[Y | X].
predictor[number, number][E[Y], 0] (the constant mean)Initial predictor line as [intercept, slope].
controlsstring[]all controls shownIds of the controls to show (see the controls registry); core ones always show. Fitted by tooling from the props and what the lecture has taught, never by hand. Absent = everything.