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
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Joint density and a conditional slice" | Title bar text. |
| jointDensity | string | "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. |
| support | string | (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. |
| rho | number | 0.6 for bivariate-normal | Correlation of the bivariate normal (strictly between -1 and 1); the initial value of the rho slider. |
| sdX | number | 1 | SD of X (bivariate normal). |
| sdY | number | 1 | SD of Y (bivariate normal). |
| muX | number | 0 | Mean of X (bivariate normal). |
| muY | number | 0 | Mean of Y (bivariate normal). |
| parameters | {name, min, max, step?, initial?, label?, description?}[] | [{"name": "rho"}] for bivariate-normal, [] otherwise | Sliders. 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] | automatic | Visible y window. |
| view | string | "both" for bivariate-normal, "heatmap" otherwise | Initial display of the joint density: heatmap, contours or both (the learner can switch). |
| conditionOn | string | "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). |
| slice | number | muX + sdX for bivariate-normal, else E[X] (or E[Y]) | Initial slice position x0 (or y0); the learner drags it. |
| showConditionToggle | boolean | true | Show the Given X / Given Y switch. |
| showMarginals | boolean | true | Initially show the marginal densities f_X along the top and f_Y along the right edge (learner toggle). |
| showConditionalMean | boolean | false | Initially draw the conditional-mean curve E[Y | X = x] (the regression line for a bivariate normal) (learner toggle). |
| showConditionalSpread | boolean | false | Initially draw E[Y | X = x] plus and minus one conditional SD (learner toggle). |
| showSlice | boolean | true | In 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). |
| compareMarginal | boolean | false | Initially overlay the marginal of the other variable on the conditional panel (equal for every slice = independence) (learner toggle). |
| region | string | (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. |
| showPredictor | boolean | false | Add 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]. |
| controls | string[] | all controls shown | Ids 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. |
PreviousNext