Pushforward density explorer
A law pushed through a map Y = g(X): the learner drags an event a ≤ Y ≤ b (or an x-interval) and sees its preimage shaded on the density of X, the branches x_i with f_X(x_i)/|g'(x_i)| that build f_Y, mapped draws filling the density of Y, the CDF method, quantiles carried by monotone maps, and wrong candidate formulas that fail to integrate to 1. A two-coordinate map instead shows a draggable cell and its image, whose area ratio is |det J|.
Used in: Introduction to Probability Theory
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Transforming a random variable" (2-D: "Jacobian of a transformation") | Title bar text. |
| distribution | object | string | {family: "normal", params: {mean: 0, sd: 1}} | Law of X, as {family, params} or a string such as "N(0, 1)", "Uniform[0, 1]", "Exp(rate=2)" (sampling-core parser: about 30 families, categorical, mixtures; the alias wrapper key xDistribution also works). Discrete laws are allowed in 1-D. In 2-D it is the law of each input coordinate (independent). |
| distribution2 | object | string | same as distribution | 2-D only: law of the second input coordinate. |
| map | string | "y = x^2" | The map. 1-D: "y = g(x)" or just "g(x)" in one variable of any name ("p = 1/(1 + e^(-eta))"); operators + - * / ^, implicit multiplication, |x|, sqrt exp ln log sin cos tan atan sinh cosh tanh abs min max floor ceil sign Phi erf logit expit, pi, e. "u = F_X(x)" (or "F_X", "cdf") applies the CDF of X (probability integral transform); "x = F^{-1}(u)" (or "quantile") applies the quantile function of target. 2-D: two coordinates separated by a comma, e.g. "y1 = x1 + x2, y2 = x1/(x1 + x2)" or the Box-Muller map in u1, u2. |
| target | object | string | Exponential(rate 1) | The law F whose quantile function F^{-1} the map "quantile" applies (continuous or discrete). |
| view | string | "density" | Initial view: "density" (densities and an event a ≤ Y ≤ b) or "cdf" (the CDF method: A_y = {x : g(x) ≤ y} and F_Y(y)). |
| showViewToggle | boolean | true | Show the Density / CDF toggle in the title bar (1-D). |
| probe | [number, number] | null | about the 35%-65% quantiles of Y (or the 45%-58% quantiles of X when probeAxis = "x") | Initial draggable event [a, b], on the y axis (a ≤ Y ≤ b) or on the x axis (probeAxis = "x"). null hides it. |
| probeAxis | string | "y" | "y": the event a ≤ Y ≤ b and its preimage g^{-1}[a, b] (with branch roots); "x": an x-interval, its image g([a, b]) and the stretch factor |g'|. |
| threshold | number | median of Y | CDF view: initial threshold y of the event Y ≤ y. |
| showBranches | boolean | true | Mark the roots x_i of g(x) = y0 (y0 = midpoint of the probe) and list f_X(x_i), |g'(x_i)| and their sum f_Y(y0). |
| showDraws | boolean | true | Show Draw / Stream buttons; draws of X are mapped through g and fill a histogram over the density of Y (2-D: scatter in both planes). |
| nDraws | number | 0 | Number of draws made on load (seeded). |
| seed | number | string | 1 | Random seed for the draws. |
| showCandidates | boolean | false | Show a selector of candidate formulas for f_Y (correct, one branch only, no Jacobian, no absolute value); the candidate is drawn dashed with its total integral. |
| candidate | string | "correct" | Initial candidate when showCandidates is on: "correct", "one-branch", "no-jacobian" or "no-abs". |
| showQuantile | boolean | false | Show a level-p slider with x_p, g(x_p), y_p and y_{1-p} (monotone maps carry quantiles; decreasing ones swap tails) and the modes of X (mapped) and Y. |
| quantileLevel | number | 0.5 | Initial quantile level p (0 < p < 1). |
| xRange | [number, number] | plotting window of X | Visible x range (2-D: both input axes). |
| yRange | [number, number] | about the 0.5%-99.5% range of Y | Visible y range (2-D: both output axes). |
| cell | [number, number] | the medians of the inputs | 2-D: initial centre of the draggable square cell. |
| cellSize | number | a tenth of the input window | 2-D: initial side h of the cell (slider). |
| showGrid | boolean | true | 2-D: draw grid lines in the input plane and their images (rings and spokes for Box-Muller). |
| controls | string[] | all controls shown | Registry ids of the hideable controls to show (see `controls` in this file): the Density / CDF toggle, the branch marks and table, the mapped draws, the integral row, the candidate and quantile panels, the mode rows and the word "independent" in 2-D. Core ones always show. Absent = everything. Fitted per page by component_scopes.py, not by hand. |