@compstats/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/README.md +127 -110
- package/dist/3d.js +1120 -122
- package/dist/3d.js.map +16 -9
- package/dist/core/arith.d.ts.map +1 -1
- package/dist/core/linalg/cov.d.ts +50 -0
- package/dist/core/linalg/cov.d.ts.map +1 -0
- package/dist/core/linalg/eigen.d.ts +53 -0
- package/dist/core/linalg/eigen.d.ts.map +1 -0
- package/dist/core/linalg/lm.d.ts +78 -0
- package/dist/core/linalg/lm.d.ts.map +1 -0
- package/dist/core/linalg/lu.d.ts +154 -0
- package/dist/core/linalg/lu.d.ts.map +1 -0
- package/dist/core/linalg/matrix.d.ts +131 -0
- package/dist/core/linalg/matrix.d.ts.map +1 -0
- package/dist/core/linalg/modelMatrix.d.ts +69 -0
- package/dist/core/linalg/modelMatrix.d.ts.map +1 -0
- package/dist/core/linalg/namedVector.d.ts +37 -0
- package/dist/core/linalg/namedVector.d.ts.map +1 -0
- package/dist/core/linalg/ops.d.ts +120 -0
- package/dist/core/linalg/ops.d.ts.map +1 -0
- package/dist/core/linalg/prcomp.d.ts +66 -0
- package/dist/core/linalg/prcomp.d.ts.map +1 -0
- package/dist/core/linalg/qr.d.ts +134 -0
- package/dist/core/linalg/qr.d.ts.map +1 -0
- package/dist/core/linalg/vector.d.ts +68 -0
- package/dist/core/linalg/vector.d.ts.map +1 -0
- package/dist/core/moderation.d.ts +6 -3
- package/dist/core/moderation.d.ts.map +1 -1
- package/dist/core/ols.d.ts +4 -7
- package/dist/core/ols.d.ts.map +1 -1
- package/dist/data/moderationData.d.ts +2 -2
- package/dist/data/pcaDegenerate.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1601 -863
- package/dist/index.js.map +17 -11
- package/dist/linalg.d.ts +36 -0
- package/dist/linalg.d.ts.map +1 -0
- package/dist/linalg.js +1860 -0
- package/dist/linalg.js.map +24 -0
- package/dist/plot/moderation3d.d.ts +1 -1
- package/dist/plot/sampling.d.ts +45 -0
- package/dist/plot/sampling.d.ts.map +1 -1
- package/dist/plot/scatter3d.d.ts +1 -1
- package/package.json +16 -5
package/dist/3d.js.map
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/plot/plotly.ts", "../src/core/frame.ts", "../src/plot/scatter3d.ts", "../src/interactive/controls.ts", "../src/plot/target.ts", "../src/interactive/target.ts", "../src/interactive/scatter3d.ts", "../src/core/arith.ts", "../src/core/
|
|
3
|
+
"sources": ["../src/plot/plotly.ts", "../src/core/frame.ts", "../src/plot/scatter3d.ts", "../src/interactive/controls.ts", "../src/plot/target.ts", "../src/interactive/target.ts", "../src/interactive/scatter3d.ts", "../src/core/arith.ts", "../src/core/special.ts", "../src/core/tdist.ts", "../src/core/linalg/matrix.ts", "../src/core/linalg/modelMatrix.ts", "../src/core/linalg/namedVector.ts", "../src/core/linalg/ops.ts", "../src/core/linalg/qr.ts", "../src/core/linalg/lm.ts", "../src/core/moderation.ts", "../src/plot/moderation3d.ts", "../src/interactive/moderation3d.ts", "../src/data/moderationData.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * The seam between this library and Plotly.js.\n *\n * The two 3D plots of the R package are drawn by Plotly (`plot_scatter3d()`)\n * and by lattice (`plot_moderation_3d()`). In a browser there is one sensible\n * engine for both, and the R package already chose it for the scatterplot, so\n * both 3D plots of this port draw through Plotly.\n *\n * Plotly is four megabytes of code. Three rules keep that weight off everyone\n * who does not draw in three dimensions.\n *\n * 1. **The 2D entry never names it.** The 3D plots live behind their own entry\n * point, `src/3d.ts`, which the package exports as `compstatslib/3d`.\n * 2. **The 3D entry does not carry it either.** `loadPlotly()` reaches the\n * library through a dynamic `import`, which a bundler keeps in a chunk of\n * its own and a browser fetches only when a plot is drawn.\n * 3. **The engine is an argument.** Both plot functions take a `plotly`\n * option. The tests pass a recorder (`test/recording-plotly.ts`) and never\n * load Plotly at all: happy-dom has no WebGL, and the work this port does\n * is the trace and the layout it builds, not the picture Plotly makes.\n *\n * `PlotlyLike` lists the exact calls the port makes, in the manner of\n * `Context2D` in `./target.ts`. The real library satisfies it, and so does\n * any object with those two methods.\n *\n * The trace and layout types below are equally narrow. They describe the\n * fields this port sets, not the several hundred Plotly accepts.\n */\n\n/** A point in three dimensions, as Plotly writes one. */\nexport interface Vector3 {\n readonly x: number;\n readonly y: number;\n readonly z: number;\n}\n\n/**\n * Where the camera stands, where it looks, and which way is up. Plotly's\n * `scene.camera`. Every part is optional: Plotly supplies its own.\n */\nexport interface PlotlyCamera {\n readonly eye?: Vector3;\n readonly center?: Vector3;\n readonly up?: Vector3;\n}\n\n/**\n * A camera whose position is known. `cameraFromRotations` returns one, so a\n * caller can read the eye without asking whether it is there.\n */\nexport interface EyeCamera extends PlotlyCamera {\n readonly eye: Vector3;\n}\n\n/** How the markers of a 3D scatterplot are drawn. */\nexport interface Scatter3dMarker {\n /** R's `opacity`, in (0, 1]. */\n readonly opacity: number;\n /** R's `size`, in pixels. */\n readonly size: number;\n /** One value per point, when a numeric column drives the color. */\n readonly color?: readonly number[];\n /** The scale those values are read through. */\n readonly colorscale?: string;\n /** Whether the scale is drawn beside the plot as a color bar. */\n readonly showscale?: boolean;\n}\n\n/** A cloud of points. */\nexport interface Scatter3dTrace {\n readonly type: \"scatter3d\";\n readonly mode: \"markers\";\n readonly x: readonly number[];\n readonly y: readonly number[];\n readonly z: readonly number[];\n readonly marker: Scatter3dMarker;\n /** The level this trace holds, when a categorical column splits the data. */\n readonly name?: string;\n /** Whether the level is listed in the legend. */\n readonly showlegend?: boolean;\n}\n\n/**\n * A height field.\n *\n * `z[j][i]` is the height above `x[i]` and `y[j]` — the row index runs along\n * `y`, which is why the moderation plot writes the moderator into the rows.\n */\nexport interface SurfaceTrace {\n readonly type: \"surface\";\n readonly x: readonly number[];\n readonly y: readonly number[];\n readonly z: readonly (readonly number[])[];\n /** Whether the height scale is drawn beside the plot. */\n readonly showscale: boolean;\n}\n\n/** Anything this port draws. */\nexport type PlotlyTrace = Scatter3dTrace | SurfaceTrace;\n\n/** One axis of a 3D scene. */\nexport interface PlotlyAxis {\n /**\n * The axis label, in Plotly's object form. Plotly v2 silently drops a\n * bare-string title, so the type refuses the shorthand that would compile\n * and then show nothing.\n */\n readonly title: { readonly text: string };\n /**\n * The values the axis spans, as `[low, high]`. Plotly fits the data when\n * the range is absent.\n */\n readonly range?: readonly [number, number];\n}\n\n/** The 3D scene: three axes, the shape of the box, and the camera. */\nexport interface PlotlyScene {\n /** `\"manual\"` reads the ratio below. The others are Plotly's own rules. */\n readonly aspectmode?: \"auto\" | \"cube\" | \"data\" | \"manual\";\n readonly aspectratio?: Vector3;\n readonly xaxis: PlotlyAxis;\n readonly yaxis: PlotlyAxis;\n readonly zaxis: PlotlyAxis;\n /**\n * A name for the view. Plotly keeps the rotation and the zoom across a\n * redraw while this string does not change, which is how a slider can\n * rebuild the plot without throwing away the angle the user chose.\n */\n readonly uirevision?: string;\n readonly camera?: PlotlyCamera;\n}\n\n/** The layout of a 3D plot. */\nexport interface PlotlyLayout {\n readonly uirevision: string;\n readonly scene: PlotlyScene;\n}\n\n/** The behavior of the plot, as opposed to its content. */\nexport interface PlotlyConfig {\n /** Whether the plot follows the size of the element that holds it. */\n readonly responsive?: boolean;\n}\n\n/**\n * What Plotly reports after the user moves the plot.\n *\n * The camera arrives under the key `scene.camera`, which is a path, not a\n * nested object. The other keys depend on what moved.\n */\nexport interface PlotlyRelayoutEvent {\n readonly \"scene.camera\"?: PlotlyCamera;\n readonly [key: string]: unknown;\n}\n\n/**\n * A change pushed at a plot that is already drawn.\n *\n * Plotly's `relayout` takes the layout attribute by its path, so the camera\n * arrives under the same `scene.camera` key it is reported under.\n */\nexport interface PlotlyRelayoutUpdate {\n readonly \"scene.camera\"?: PlotlyCamera;\n}\n\n/**\n * The element Plotly hands back after it has drawn.\n *\n * Plotly adds an event emitter to that element, which is the only way to learn\n * that the user rotated the plot.\n */\nexport interface PlotlyHTMLElement extends HTMLElement {\n on(\n event: \"plotly_relayout\",\n handler: (event: PlotlyRelayoutEvent) => void,\n ): void;\n removeAllListeners(event: string): void;\n}\n\n/**\n * The part of Plotly this library calls.\n *\n * `react` both draws and updates: on an empty element it builds the plot, and\n * on one that already holds a plot it changes only what differs.\n *\n * `relayout` exists for one case that `react` cannot serve. The layouts of\n * this port carry a constant `uirevision`, which is what keeps a user's own\n * rotation across a redraw; Plotly honours that literally, so once the user\n * has dragged the plot, a `react` carrying a different `scene.camera` is\n * ignored. The rotation sliders of the moderation surface would then move\n * nothing. `relayout` is an instruction rather than a preference, so it moves\n * the camera whatever the user did before, and it is called only when a\n * slider asks for a view the plot is not already at.\n */\nexport interface PlotlyLike {\n react(\n element: HTMLElement,\n data: readonly PlotlyTrace[],\n layout: PlotlyLayout,\n config?: PlotlyConfig,\n ): Promise<PlotlyHTMLElement>;\n /** Change one part of the layout of a plot that is already drawn. */\n relayout(\n element: HTMLElement,\n update: PlotlyRelayoutUpdate,\n ): Promise<PlotlyHTMLElement>;\n /** Remove the plot, and everything it attached to the element. */\n purge(element: HTMLElement): void;\n}\n\n/**\n * Whether two cameras stand at the same view.\n *\n * The interactive components write a camera the user dragged to back into the\n * live layout, and the `relayout` that does so fires `plotly_relayout` again\n * with the same camera as a fresh object. Comparing by value is what lets the\n * capture handlers recognize that echo and stop, so this must never be\n * replaced with a reference comparison.\n *\n * @param a One camera, or nothing.\n * @param b The other, or nothing.\n * @returns True when both are absent, or both present with equal parts.\n */\nexport function sameCamera(\n a: PlotlyCamera | undefined,\n b: PlotlyCamera | undefined,\n): boolean {\n if (a === undefined || b === undefined) {\n return a === b;\n }\n return (\n sameVector(a.eye, b.eye) &&\n sameVector(a.center, b.center) &&\n sameVector(a.up, b.up)\n );\n}\n\n/** Whether two optional vectors carry the same coordinates. */\nfunction sameVector(a: Vector3 | undefined, b: Vector3 | undefined): boolean {\n if (a === undefined || b === undefined) {\n return a === b;\n }\n return a.x === b.x && a.y === b.y && a.z === b.z;\n}\n\n/** The one load, shared by every caller. */\nlet loading: Promise<PlotlyLike> | undefined;\n\n/**\n * Load Plotly.js.\n *\n * The library is fetched once. Every later call gets the same promise, so two\n * plots on one page load one copy.\n *\n * @returns The library, narrowed to the calls this port makes.\n */\nexport function loadPlotly(): Promise<PlotlyLike> {\n loading ??= import(\"plotly.js-dist-min\").then((module) => {\n const loaded = (module as { readonly default?: unknown }).default ?? module;\n return loaded as PlotlyLike;\n });\n return loading;\n}\n",
|
|
6
6
|
"/**\n * Column-keyed data frames, and the checks R gets for free.\n *\n * The 3D functions of the R package take an R data frame, which guarantees\n * two things a JavaScript object does not: every column holds one type, and\n * every column has the same length. `moderation.ts` and the scatter3d module\n * both need those guarantees, so the questions are asked in one place and\n * answered the same way for both.\n *\n * The port follows `../compstatslib/R/scatter3d_helpers.R`:\n *\n * ```r\n * scatter3d_numeric_cols <- function(data) {\n * names(data)[vapply(data, is.numeric, logical(1))]\n * }\n * ```\n *\n * with two departures, both forced by the language and both pinned by tests.\n * R reads a vector's declared type, so `is.numeric(numeric(0))` is TRUE and a\n * column of mixed types cannot exist. A JavaScript array declares nothing, so\n * this module reads the values: **a column is numeric when it holds at least\n * one value and every value is a number.** An empty column therefore is not\n * numeric — it offers no evidence either way, and an empty axis draws nothing\n * — and a column of numbers with one string in it is not numeric either,\n * because fitting it would give `NaN` for every coefficient.\n */\n\n/**\n * One column of a data frame.\n *\n * Numeric columns carry the statistics. The other two types are here because\n * `plot_scatter3d()` accepts a categorical column for `color`, which R allows\n * to be a factor, a character vector, or a logical vector.\n */\nexport type Column = readonly number[] | readonly string[] | readonly boolean[];\n\n/**\n * A data frame: named columns of equal length.\n *\n * The equal length is a rule, not a type. `frameRows` enforces it.\n */\nexport type DataFrame = { readonly [name: string]: Column };\n\n/**\n * Report whether a column holds numbers, and narrow it when it does.\n *\n * @param column The column to inspect.\n * @returns True when the column has at least one value and every value is a\n * number. `NaN` counts as a number, as R's missing values do.\n */\nexport function isNumericColumn(column: Column): column is readonly number[] {\n return column.length > 0 && column.every((value) => typeof value === \"number\");\n}\n\n/**\n * Name the numeric columns, in the order the frame declares them.\n *\n * This is R's `scatter3d_numeric_cols()`. The order matters: the scatter3d\n * default takes the first three names this returns.\n *\n * @param data The frame to inspect.\n * @returns The names of the numeric columns, in insertion order.\n */\nexport function numericColumns(data: DataFrame): string[] {\n return Object.keys(data).filter((name) =>\n isNumericColumn(data[name] as Column),\n );\n}\n\n/**\n * Refuse a frame that cannot fill three numeric axes.\n *\n * This is R's `scatter3d_require_3_numeric()`, which both the plot and the\n * gadget call with their own name, so that the message says which function\n * the caller reached.\n *\n * @param numeric The numeric column names, from `numericColumns`.\n * @param caller The name to print, such as `plotScatter3d`.\n * @throws RangeError If fewer than three names were given.\n */\nexport function requireThreeNumericColumns(\n numeric: readonly string[],\n caller: string,\n): void {\n if (numeric.length < 3) {\n throw new RangeError(\n `${caller}() needs at least 3 numeric columns; got ${numeric.length}. ` +\n \"Supply x/y/z explicitly or add numeric columns.\",\n );\n }\n}\n\n/**\n * Return the number of rows, and refuse a frame that has no single answer.\n *\n * @param data The frame to measure.\n * @returns The shared length of the columns. A frame with no columns has no\n * rows.\n * @throws RangeError If two columns have different lengths. An R data frame\n * cannot be built that way, so nothing downstream is written to survive it.\n */\nexport function frameRows(data: DataFrame): number {\n const names = Object.keys(data);\n const first = names[0];\n if (first === undefined) {\n return 0;\n }\n\n const rows = (data[first] as Column).length;\n const ragged = names.find((name) => (data[name] as Column).length !== rows);\n if (ragged !== undefined) {\n throw new RangeError(\n `every column needs the same number of rows: \"${first}\" has ${rows} ` +\n `but \"${ragged}\" has ${(data[ragged] as Column).length}`,\n );\n }\n\n return rows;\n}\n\n/**\n * Read one numeric column, or explain why it cannot be used.\n *\n * The wording follows R's own, which names both the column and the argument\n * it arrived through: `Column \"b\" (passed as \\`x\\`) is not in \\`data\\`.`\n *\n * @param data The frame to read.\n * @param name The column name the caller asked for.\n * @param role The option that carried the name, such as `iv` or `mod`. It\n * appears in the error, so the caller learns which argument is wrong.\n * @returns The column.\n * @throws RangeError If the frame has no such column, or the column is not\n * numeric.\n */\nexport function requireNumericColumn(\n data: DataFrame,\n name: string,\n role: string,\n): readonly number[] {\n const column = data[name];\n if (column === undefined) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${role}\\`) is not in the data.`,\n );\n }\n if (!isNumericColumn(column)) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${role}\\`) is not numeric; ` +\n \"only numeric columns can carry the statistics.\",\n );\n }\n\n return column;\n}\n",
|
|
7
|
-
"/**\n * The 3D scatterplot: three numeric columns as a cloud of points, with an\n * optional fourth column driving the color.\n *\n * This is `plot_scatter3d()` of `../compstatslib/R/scatter3d_plot.R`, drawn\n * through Plotly as the R original is. The trace and the layout follow the\n * object R actually builds, dumped in `.claude/plans/moderation-fixtures.md`\n * section 5.\n *\n * Four things are worth knowing before reading the code.\n *\n * **The work is the specification.** `scatter3dSpec` builds the traces and the\n * layout and touches nothing outside itself. `plotScatter3d` resolves the\n * engine and draws that specification. The split keeps every rule of the port\n * testable without a browser, and it gives the interactive layer a cheap way\n * to ask what a set of options would draw.\n *\n * **Nothing is drawn until everything is checked.** R validates the style,\n * then the axis arguments, then the columns, and only then calls Plotly. That\n * order was confirmed by tracing `plot_ly()`: every error fires with the\n * engine untouched. This module keeps the order and the wording, and the tests\n * count the calls to prove it.\n *\n * **The default axes are the first three numeric columns, in frame order.**\n * With the bundled `moderation_data` that is `y, x, z`, so the plot's own x\n * axis is titled \"y\". The collision is confusing, and it is R's, so the port\n * keeps it. A note names the chosen and the skipped columns, as R's\n * `message()` does; a library cannot write to a console, so the note is\n * returned and the caller decides whether to show it.\n *\n * **Color is the one place the port must invent.** R hands the color column\n * to plotly-R, which decides by itself what a numeric or a categorical column\n * means. Plotly.js decides nothing: the caller must build the traces. So a\n * numeric column becomes one trace carrying a value per point with a color\n * bar beside it, and a categorical column becomes one trace per level, named,\n * listed in the legend, and colored from Plotly's own sequence. The rule\n * follows what plotly-R does; the exact colors are Plotly's choice, in both\n * languages.\n */\n\nimport {\n frameRows,\n isNumericColumn,\n numericColumns,\n requireThreeNumericColumns,\n} from \"../core/frame\";\nimport type { Column, DataFrame } from \"../core/frame\";\nimport { loadPlotly } from \"./plotly\";\nimport type {\n PlotlyCamera,\n PlotlyHTMLElement,\n PlotlyLayout,\n PlotlyLike,\n Scatter3dMarker,\n Scatter3dTrace,\n} from \"./plotly\";\n\n/**\n * The name Plotly keeps the view under. R sets the same literal string, in\n * both the layout and the scene.\n */\nconst UIREVISION = \"scatter3d\";\n/**\n * The scale a numeric color column is read through. plotly-R colors a\n * numeric column with Viridis by default, so the port names it here.\n */\nconst NUMERIC_COLORSCALE = \"Viridis\";\n/** Plotly redraws the plot when the element that holds it changes size. */\nconst CONFIG = { responsive: true } as const;\n\n/** How the markers are drawn, apart from the data. */\nexport interface Scatter3dStyle {\n /** The x, y and z proportions of the box the points sit in. */\n readonly aspect: readonly number[];\n /** How solid each marker is, in (0, 1]. */\n readonly opacity: number;\n /** How large each marker is, in pixels. */\n readonly size: number;\n}\n\n/**\n * R's own defaults: `aspect = c(1, 1, 1), opacity = 0.8, size = 5`.\n *\n * `interactive_scatter3d()` repeats these three numbers in its own signature.\n * The port states them once, here, so the gadget's sliders and the plot they\n * drive cannot start from different places.\n */\nexport const DEFAULT_SCATTER3D_STYLE: Scatter3dStyle = {\n aspect: [1, 1, 1],\n opacity: 0.8,\n size: 5,\n};\n\n/** Titles to write on the axes instead of the column names. */\nexport interface Scatter3dTitles {\n readonly x?: string;\n readonly y?: string;\n readonly z?: string;\n}\n\n/** What to draw, and how. Every option is R's, with R's default. */\nexport interface Scatter3dSpecOptions {\n /** The column on the first horizontal axis. */\n readonly x?: string;\n /** The column on the second horizontal axis. */\n readonly y?: string;\n /** The column on the vertical axis. */\n readonly z?: string;\n /**\n * Any column to map to color. A numeric column gives a continuous scale\n * with a color bar; a text or true-or-false column gives one trace per\n * level, with a legend.\n */\n readonly color?: string;\n /**\n * The x, y and z proportions of the box the points sit in: three positive\n * numbers, `[1, 1, 1]` by default.\n */\n readonly aspect?: readonly number[];\n /** How solid each marker is, in (0, 1]. */\n readonly opacity?: number;\n /** How large each marker is, in pixels. */\n readonly size?: number;\n /**\n * Where the camera starts. Absent by default, which leaves Plotly's own\n * view. Pass a camera to reopen a plot at an angle captured earlier.\n */\n readonly camera?: PlotlyCamera;\n /** Axis titles. Each axis falls back to the name of its column. */\n readonly titles?: Scatter3dTitles;\n}\n\n/** The options of `plotScatter3d`: the specification, and the engine. */\nexport interface PlotScatter3dOptions extends Scatter3dSpecOptions {\n /**\n * The Plotly engine. `loadPlotly()` by default, which fetches the library on\n * first use. Pass your own to draw through a copy you already hold, or to\n * record what would be drawn.\n */\n readonly plotly?: PlotlyLike;\n}\n\n/** What a set of options draws. */\nexport interface Scatter3dSpec {\n /** One trace, or one for each level of a categorical color column. */\n readonly traces: readonly Scatter3dTrace[];\n readonly layout: PlotlyLayout;\n /**\n * What R says in its `message()`: which columns were chosen, and which were\n * skipped. Null when the caller named every axis, or when no numeric column\n * was left over.\n */\n readonly note: string | null;\n}\n\n/** A drawn scatterplot: its specification, its element, and its engine. */\nexport interface Scatter3dHandle extends Scatter3dSpec {\n /**\n * The element Plotly drew into. Plotly returns it with an event emitter\n * attached, which is how the interactive layer hears about rotation.\n */\n readonly element: PlotlyHTMLElement;\n /** The engine that drew, ready for the next redraw and for teardown. */\n readonly plotly: PlotlyLike;\n}\n\n/**\n * Build the traces and the layout of a 3D scatterplot.\n *\n * @param data The frame to read.\n * @param options Which columns to draw, and how.\n * @returns The traces, the layout, and the note about the column choice.\n * @throws RangeError If the style is out of range, if the frame is ragged, if\n * fewer than three numeric columns are available, or if a named column is\n * absent or, on an axis, not numeric.\n */\nexport function scatter3dSpec(\n data: DataFrame,\n options: Scatter3dSpecOptions = {},\n): Scatter3dSpec {\n const {\n aspect = DEFAULT_SCATTER3D_STYLE.aspect,\n opacity = DEFAULT_SCATTER3D_STYLE.opacity,\n size = DEFAULT_SCATTER3D_STYLE.size,\n camera,\n titles,\n color,\n } = options;\n\n // R's order: the style first, and nothing else read until it passes.\n validateScatter3dStyle(aspect, opacity, size);\n // R cannot hold a ragged data frame. A JavaScript object can, and the rest\n // of this function would read past the end of the shorter column.\n frameRows(data);\n\n const { axes, note } = chooseAxes(data, options);\n const points = {\n x: requireAxisColumn(data, axes.x, \"x\"),\n y: requireAxisColumn(data, axes.y, \"y\"),\n z: requireAxisColumn(data, axes.z, \"z\"),\n };\n\n const colorColumn = color === undefined ? undefined : data[color];\n if (color !== undefined && colorColumn === undefined) {\n throw new RangeError(\n `Column \"${color}\" (passed as \\`color\\`) is not in the data.`,\n );\n }\n\n const traces = buildTraces(points, { opacity, size }, colorColumn);\n const shown = { x: axes.x, y: axes.y, z: axes.z, ...titles };\n const layout: PlotlyLayout = {\n uirevision: UIREVISION,\n scene: {\n aspectmode: \"manual\",\n aspectratio: {\n x: aspect[0] as number,\n y: aspect[1] as number,\n z: aspect[2] as number,\n },\n xaxis: { title: { text: shown.x } },\n yaxis: { title: { text: shown.y } },\n zaxis: { title: { text: shown.z } },\n uirevision: UIREVISION,\n ...(camera === undefined ? {} : { camera }),\n },\n };\n\n return { traces, layout, note };\n}\n\n/**\n * Draw a 3D scatterplot.\n *\n * @param target The element to draw into. Plotly fills it.\n * @param data The frame to read.\n * @param options Which columns to draw, how, and through which engine.\n * @returns The drawn plot: its element, its specification, and its engine.\n * @throws RangeError Everything `scatter3dSpec` throws, as a rejected promise.\n * No option reaches the engine until every check has passed.\n */\nexport async function plotScatter3d(\n target: HTMLElement,\n data: DataFrame,\n options: PlotScatter3dOptions = {},\n): Promise<Scatter3dHandle> {\n const { plotly, ...specOptions } = options;\n const spec = scatter3dSpec(data, specOptions);\n const engine = plotly ?? (await loadPlotly());\n const element = await engine.react(target, spec.traces, spec.layout, CONFIG);\n\n return { ...spec, element, plotly: engine };\n}\n\n/**\n * R's `scatter3d_validate_style()`, less the checks the compiler makes.\n *\n * Exported because R shares this check between the plot and the gadget, and\n * the gadget runs it before it builds anything. Note what it does **not** do:\n * it refuses a style no plot could be drawn with, and says nothing about the\n * bounds of the gadget's sliders. An aspect of 12 passes here and is then\n * clamped by the slider, which is R's behavior exactly.\n *\n * @param aspect The three axis proportions.\n * @param opacity How solid a marker is.\n * @param size How large a marker is.\n * @throws RangeError With R's own wording, in R's own order.\n */\nexport function validateScatter3dStyle(\n aspect: readonly number[],\n opacity: number,\n size: number,\n): void {\n // R also refuses a camera that is not a list, and an axis name that is not a\n // string. Both are compiler errors here, so neither check is written.\n if (aspect.length !== 3 || !aspect.every((value) => Number.isFinite(value))) {\n throw new RangeError(\"`aspect` must be a numeric vector of length 3.\");\n }\n if (aspect.some((value) => value <= 0)) {\n throw new RangeError(\"`aspect` values must all be positive.\");\n }\n if (!Number.isFinite(opacity) || opacity <= 0 || opacity > 1) {\n throw new RangeError(\"`opacity` must be a single numeric in (0, 1].\");\n }\n if (!Number.isFinite(size) || size <= 0) {\n throw new RangeError(\"`size` must be a single positive numeric.\");\n }\n}\n\n/**\n * Settle which column goes on which axis.\n *\n * R fills every axis it was not given from the first three numeric columns,\n * and reports the choice whenever a numeric column was left over.\n */\nfunction chooseAxes(\n data: DataFrame,\n options: Scatter3dSpecOptions,\n): {\n readonly axes: { readonly x: string; readonly y: string; readonly z: string };\n readonly note: string | null;\n} {\n const { x, y, z } = options;\n if (x !== undefined && y !== undefined && z !== undefined) {\n return { axes: { x, y, z }, note: null };\n }\n\n const numeric = numericColumns(data);\n requireThreeNumericColumns(numeric, \"plotScatter3d\");\n\n const chosen = numeric.slice(0, 3) as [string, string, string];\n const skipped = numeric.slice(3);\n const note =\n skipped.length === 0\n ? null\n : `plotScatter3d(): using numeric columns ${chosen.join(\", \")}; ` +\n `skipped ${skipped.join(\", \")}. Pass x/y/z to choose explicitly.`;\n\n return {\n axes: { x: x ?? chosen[0], y: y ?? chosen[1], z: z ?? chosen[2] },\n note,\n };\n}\n\n/**\n * Read one axis column.\n *\n * The wording is R's, which names the column, the argument it arrived through,\n * what the column holds, and where a categorical column belongs instead.\n */\nfunction requireAxisColumn(\n data: DataFrame,\n name: string,\n axis: string,\n): readonly number[] {\n const column = data[name];\n if (column === undefined) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${axis}\\`) is not in the data.`,\n );\n }\n if (!isNumericColumn(column)) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${axis}\\`) is ${describe(column)}; ` +\n \"plotScatter3d() requires numeric columns on x/y/z. \" +\n \"Use `color` for categorical separation.\",\n );\n }\n return column;\n}\n\n/** Say what a column holds, where R names the column's class. */\nfunction describe(column: Column): string {\n const kinds = new Set<string>(column.map((value) => typeof value));\n if (kinds.size === 0) {\n return \"empty\";\n }\n if (kinds.size > 1) {\n return \"mixed\";\n }\n if (kinds.has(\"string\")) {\n return \"text\";\n }\n return kinds.has(\"boolean\") ? \"true or false\" : \"numbers\";\n}\n\n/** Build the trace, or the traces, that carry the points. */\nfunction buildTraces(\n points: {\n readonly x: readonly number[];\n readonly y: readonly number[];\n readonly z: readonly number[];\n },\n marker: Scatter3dMarker,\n color: Column | undefined,\n): readonly Scatter3dTrace[] {\n if (color === undefined) {\n return [{ type: \"scatter3d\", mode: \"markers\", ...points, marker }];\n }\n\n if (isNumericColumn(color)) {\n return [\n {\n type: \"scatter3d\",\n mode: \"markers\",\n ...points,\n marker: {\n ...marker,\n color,\n colorscale: NUMERIC_COLORSCALE,\n showscale: true,\n },\n },\n ];\n }\n\n // One trace for each level, in the order the levels first appear, which is\n // the order Plotly then lists them in the legend.\n const levels = [...new Set(color.map((value) => String(value)))];\n return levels.map((level) => {\n const rows = color.flatMap((value, row) =>\n String(value) === level ? [row] : [],\n );\n return {\n type: \"scatter3d\",\n mode: \"markers\",\n x: rows.map((row) => points.x[row] as number),\n y: rows.map((row) => points.y[row] as number),\n z: rows.map((row) => points.z[row] as number),\n marker,\n name: level,\n showlegend: true,\n };\n });\n}\n",
|
|
7
|
+
"/**\n * The 3D scatterplot: three numeric columns as a cloud of points, with an\n * optional fourth column driving the color.\n *\n * This is `plot_scatter3d()` of `../compstatslib/R/scatter3d_plot.R`, drawn\n * through Plotly as the R original is. The trace and the layout follow the\n * object R actually builds, dumped in `.claude/plans/001-PLAN-port/moderation-fixtures.md`\n * section 5.\n *\n * Four things are worth knowing before reading the code.\n *\n * **The work is the specification.** `scatter3dSpec` builds the traces and the\n * layout and touches nothing outside itself. `plotScatter3d` resolves the\n * engine and draws that specification. The split keeps every rule of the port\n * testable without a browser, and it gives the interactive layer a cheap way\n * to ask what a set of options would draw.\n *\n * **Nothing is drawn until everything is checked.** R validates the style,\n * then the axis arguments, then the columns, and only then calls Plotly. That\n * order was confirmed by tracing `plot_ly()`: every error fires with the\n * engine untouched. This module keeps the order and the wording, and the tests\n * count the calls to prove it.\n *\n * **The default axes are the first three numeric columns, in frame order.**\n * With the bundled `moderation_data` that is `y, x, z`, so the plot's own x\n * axis is titled \"y\". The collision is confusing, and it is R's, so the port\n * keeps it. A note names the chosen and the skipped columns, as R's\n * `message()` does; a library cannot write to a console, so the note is\n * returned and the caller decides whether to show it.\n *\n * **Color is the one place the port must invent.** R hands the color column\n * to plotly-R, which decides by itself what a numeric or a categorical column\n * means. Plotly.js decides nothing: the caller must build the traces. So a\n * numeric column becomes one trace carrying a value per point with a color\n * bar beside it, and a categorical column becomes one trace per level, named,\n * listed in the legend, and colored from Plotly's own sequence. The rule\n * follows what plotly-R does; the exact colors are Plotly's choice, in both\n * languages.\n */\n\nimport {\n frameRows,\n isNumericColumn,\n numericColumns,\n requireThreeNumericColumns,\n} from \"../core/frame\";\nimport type { Column, DataFrame } from \"../core/frame\";\nimport { loadPlotly } from \"./plotly\";\nimport type {\n PlotlyCamera,\n PlotlyHTMLElement,\n PlotlyLayout,\n PlotlyLike,\n Scatter3dMarker,\n Scatter3dTrace,\n} from \"./plotly\";\n\n/**\n * The name Plotly keeps the view under. R sets the same literal string, in\n * both the layout and the scene.\n */\nconst UIREVISION = \"scatter3d\";\n/**\n * The scale a numeric color column is read through. plotly-R colors a\n * numeric column with Viridis by default, so the port names it here.\n */\nconst NUMERIC_COLORSCALE = \"Viridis\";\n/** Plotly redraws the plot when the element that holds it changes size. */\nconst CONFIG = { responsive: true } as const;\n\n/** How the markers are drawn, apart from the data. */\nexport interface Scatter3dStyle {\n /** The x, y and z proportions of the box the points sit in. */\n readonly aspect: readonly number[];\n /** How solid each marker is, in (0, 1]. */\n readonly opacity: number;\n /** How large each marker is, in pixels. */\n readonly size: number;\n}\n\n/**\n * R's own defaults: `aspect = c(1, 1, 1), opacity = 0.8, size = 5`.\n *\n * `interactive_scatter3d()` repeats these three numbers in its own signature.\n * The port states them once, here, so the gadget's sliders and the plot they\n * drive cannot start from different places.\n */\nexport const DEFAULT_SCATTER3D_STYLE: Scatter3dStyle = {\n aspect: [1, 1, 1],\n opacity: 0.8,\n size: 5,\n};\n\n/** Titles to write on the axes instead of the column names. */\nexport interface Scatter3dTitles {\n readonly x?: string;\n readonly y?: string;\n readonly z?: string;\n}\n\n/** What to draw, and how. Every option is R's, with R's default. */\nexport interface Scatter3dSpecOptions {\n /** The column on the first horizontal axis. */\n readonly x?: string;\n /** The column on the second horizontal axis. */\n readonly y?: string;\n /** The column on the vertical axis. */\n readonly z?: string;\n /**\n * Any column to map to color. A numeric column gives a continuous scale\n * with a color bar; a text or true-or-false column gives one trace per\n * level, with a legend.\n */\n readonly color?: string;\n /**\n * The x, y and z proportions of the box the points sit in: three positive\n * numbers, `[1, 1, 1]` by default.\n */\n readonly aspect?: readonly number[];\n /** How solid each marker is, in (0, 1]. */\n readonly opacity?: number;\n /** How large each marker is, in pixels. */\n readonly size?: number;\n /**\n * Where the camera starts. Absent by default, which leaves Plotly's own\n * view. Pass a camera to reopen a plot at an angle captured earlier.\n */\n readonly camera?: PlotlyCamera;\n /** Axis titles. Each axis falls back to the name of its column. */\n readonly titles?: Scatter3dTitles;\n}\n\n/** The options of `plotScatter3d`: the specification, and the engine. */\nexport interface PlotScatter3dOptions extends Scatter3dSpecOptions {\n /**\n * The Plotly engine. `loadPlotly()` by default, which fetches the library on\n * first use. Pass your own to draw through a copy you already hold, or to\n * record what would be drawn.\n */\n readonly plotly?: PlotlyLike;\n}\n\n/** What a set of options draws. */\nexport interface Scatter3dSpec {\n /** One trace, or one for each level of a categorical color column. */\n readonly traces: readonly Scatter3dTrace[];\n readonly layout: PlotlyLayout;\n /**\n * What R says in its `message()`: which columns were chosen, and which were\n * skipped. Null when the caller named every axis, or when no numeric column\n * was left over.\n */\n readonly note: string | null;\n}\n\n/** A drawn scatterplot: its specification, its element, and its engine. */\nexport interface Scatter3dHandle extends Scatter3dSpec {\n /**\n * The element Plotly drew into. Plotly returns it with an event emitter\n * attached, which is how the interactive layer hears about rotation.\n */\n readonly element: PlotlyHTMLElement;\n /** The engine that drew, ready for the next redraw and for teardown. */\n readonly plotly: PlotlyLike;\n}\n\n/**\n * Build the traces and the layout of a 3D scatterplot.\n *\n * @param data The frame to read.\n * @param options Which columns to draw, and how.\n * @returns The traces, the layout, and the note about the column choice.\n * @throws RangeError If the style is out of range, if the frame is ragged, if\n * fewer than three numeric columns are available, or if a named column is\n * absent or, on an axis, not numeric.\n */\nexport function scatter3dSpec(\n data: DataFrame,\n options: Scatter3dSpecOptions = {},\n): Scatter3dSpec {\n const {\n aspect = DEFAULT_SCATTER3D_STYLE.aspect,\n opacity = DEFAULT_SCATTER3D_STYLE.opacity,\n size = DEFAULT_SCATTER3D_STYLE.size,\n camera,\n titles,\n color,\n } = options;\n\n // R's order: the style first, and nothing else read until it passes.\n validateScatter3dStyle(aspect, opacity, size);\n // R cannot hold a ragged data frame. A JavaScript object can, and the rest\n // of this function would read past the end of the shorter column.\n frameRows(data);\n\n const { axes, note } = chooseAxes(data, options);\n const points = {\n x: requireAxisColumn(data, axes.x, \"x\"),\n y: requireAxisColumn(data, axes.y, \"y\"),\n z: requireAxisColumn(data, axes.z, \"z\"),\n };\n\n const colorColumn = color === undefined ? undefined : data[color];\n if (color !== undefined && colorColumn === undefined) {\n throw new RangeError(\n `Column \"${color}\" (passed as \\`color\\`) is not in the data.`,\n );\n }\n\n const traces = buildTraces(points, { opacity, size }, colorColumn);\n const shown = { x: axes.x, y: axes.y, z: axes.z, ...titles };\n const layout: PlotlyLayout = {\n uirevision: UIREVISION,\n scene: {\n aspectmode: \"manual\",\n aspectratio: {\n x: aspect[0] as number,\n y: aspect[1] as number,\n z: aspect[2] as number,\n },\n xaxis: { title: { text: shown.x } },\n yaxis: { title: { text: shown.y } },\n zaxis: { title: { text: shown.z } },\n uirevision: UIREVISION,\n ...(camera === undefined ? {} : { camera }),\n },\n };\n\n return { traces, layout, note };\n}\n\n/**\n * Draw a 3D scatterplot.\n *\n * @param target The element to draw into. Plotly fills it.\n * @param data The frame to read.\n * @param options Which columns to draw, how, and through which engine.\n * @returns The drawn plot: its element, its specification, and its engine.\n * @throws RangeError Everything `scatter3dSpec` throws, as a rejected promise.\n * No option reaches the engine until every check has passed.\n */\nexport async function plotScatter3d(\n target: HTMLElement,\n data: DataFrame,\n options: PlotScatter3dOptions = {},\n): Promise<Scatter3dHandle> {\n const { plotly, ...specOptions } = options;\n const spec = scatter3dSpec(data, specOptions);\n const engine = plotly ?? (await loadPlotly());\n const element = await engine.react(target, spec.traces, spec.layout, CONFIG);\n\n return { ...spec, element, plotly: engine };\n}\n\n/**\n * R's `scatter3d_validate_style()`, less the checks the compiler makes.\n *\n * Exported because R shares this check between the plot and the gadget, and\n * the gadget runs it before it builds anything. Note what it does **not** do:\n * it refuses a style no plot could be drawn with, and says nothing about the\n * bounds of the gadget's sliders. An aspect of 12 passes here and is then\n * clamped by the slider, which is R's behavior exactly.\n *\n * @param aspect The three axis proportions.\n * @param opacity How solid a marker is.\n * @param size How large a marker is.\n * @throws RangeError With R's own wording, in R's own order.\n */\nexport function validateScatter3dStyle(\n aspect: readonly number[],\n opacity: number,\n size: number,\n): void {\n // R also refuses a camera that is not a list, and an axis name that is not a\n // string. Both are compiler errors here, so neither check is written.\n if (aspect.length !== 3 || !aspect.every((value) => Number.isFinite(value))) {\n throw new RangeError(\"`aspect` must be a numeric vector of length 3.\");\n }\n if (aspect.some((value) => value <= 0)) {\n throw new RangeError(\"`aspect` values must all be positive.\");\n }\n if (!Number.isFinite(opacity) || opacity <= 0 || opacity > 1) {\n throw new RangeError(\"`opacity` must be a single numeric in (0, 1].\");\n }\n if (!Number.isFinite(size) || size <= 0) {\n throw new RangeError(\"`size` must be a single positive numeric.\");\n }\n}\n\n/**\n * Settle which column goes on which axis.\n *\n * R fills every axis it was not given from the first three numeric columns,\n * and reports the choice whenever a numeric column was left over.\n */\nfunction chooseAxes(\n data: DataFrame,\n options: Scatter3dSpecOptions,\n): {\n readonly axes: { readonly x: string; readonly y: string; readonly z: string };\n readonly note: string | null;\n} {\n const { x, y, z } = options;\n if (x !== undefined && y !== undefined && z !== undefined) {\n return { axes: { x, y, z }, note: null };\n }\n\n const numeric = numericColumns(data);\n requireThreeNumericColumns(numeric, \"plotScatter3d\");\n\n const chosen = numeric.slice(0, 3) as [string, string, string];\n const skipped = numeric.slice(3);\n const note =\n skipped.length === 0\n ? null\n : `plotScatter3d(): using numeric columns ${chosen.join(\", \")}; ` +\n `skipped ${skipped.join(\", \")}. Pass x/y/z to choose explicitly.`;\n\n return {\n axes: { x: x ?? chosen[0], y: y ?? chosen[1], z: z ?? chosen[2] },\n note,\n };\n}\n\n/**\n * Read one axis column.\n *\n * The wording is R's, which names the column, the argument it arrived through,\n * what the column holds, and where a categorical column belongs instead.\n */\nfunction requireAxisColumn(\n data: DataFrame,\n name: string,\n axis: string,\n): readonly number[] {\n const column = data[name];\n if (column === undefined) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${axis}\\`) is not in the data.`,\n );\n }\n if (!isNumericColumn(column)) {\n throw new RangeError(\n `Column \"${name}\" (passed as \\`${axis}\\`) is ${describe(column)}; ` +\n \"plotScatter3d() requires numeric columns on x/y/z. \" +\n \"Use `color` for categorical separation.\",\n );\n }\n return column;\n}\n\n/** Say what a column holds, where R names the column's class. */\nfunction describe(column: Column): string {\n const kinds = new Set<string>(column.map((value) => typeof value));\n if (kinds.size === 0) {\n return \"empty\";\n }\n if (kinds.size > 1) {\n return \"mixed\";\n }\n if (kinds.has(\"string\")) {\n return \"text\";\n }\n return kinds.has(\"boolean\") ? \"true or false\" : \"numbers\";\n}\n\n/** Build the trace, or the traces, that carry the points. */\nfunction buildTraces(\n points: {\n readonly x: readonly number[];\n readonly y: readonly number[];\n readonly z: readonly number[];\n },\n marker: Scatter3dMarker,\n color: Column | undefined,\n): readonly Scatter3dTrace[] {\n if (color === undefined) {\n return [{ type: \"scatter3d\", mode: \"markers\", ...points, marker }];\n }\n\n if (isNumericColumn(color)) {\n return [\n {\n type: \"scatter3d\",\n mode: \"markers\",\n ...points,\n marker: {\n ...marker,\n color,\n colorscale: NUMERIC_COLORSCALE,\n showscale: true,\n },\n },\n ];\n }\n\n // One trace for each level, in the order the levels first appear, which is\n // the order Plotly then lists them in the legend.\n const levels = [...new Set(color.map((value) => String(value)))];\n return levels.map((level) => {\n const rows = color.flatMap((value, row) =>\n String(value) === level ? [row] : [],\n );\n return {\n type: \"scatter3d\",\n mode: \"markers\",\n x: rows.map((row) => points.x[row] as number),\n y: rows.map((row) => points.y[row] as number),\n z: rows.map((row) => points.z[row] as number),\n marker,\n name: level,\n showlegend: true,\n };\n });\n}\n",
|
|
8
8
|
"/**\n * The controls the 3D components build, and the rule for where a slider may\n * stand.\n *\n * Both 3D gadgets of the R package are panels of shiny inputs above a plot,\n * and both need the same three things: a labeled slider that shows its own\n * value, a labeled picker, and a line of text for what R would have written\n * to the console. They are here so that the two components differ in what\n * they control, not in how a control is made.\n *\n * The 2D components came first and built their controls inline. The reuse\n * audit at the end of the port found the same builders written out again in\n * each of them, so they share this module too: `interactiveTTest` and\n * `interactiveMatrixInverse` for the slider and the standing rule,\n * `interactiveSampling` for the picker.\n */\n\n/** Where a slider may stand: R's `min`, `max` and `step`. */\nexport interface SliderRange {\n readonly min: number;\n readonly max: number;\n readonly step: number;\n}\n\n/** A control, its label, and the element the component listens to. */\nexport interface BuiltSlider {\n /** The label element that holds the caption, the value, and the input. */\n readonly wrapper: HTMLElement;\n readonly input: HTMLInputElement;\n /** The element that shows the current value beside the caption. */\n readonly readout: HTMLElement;\n}\n\n/** A picker, its label, and the element the component listens to. */\nexport interface BuiltSelect {\n readonly wrapper: HTMLElement;\n readonly input: HTMLSelectElement;\n}\n\n/** A line of text for what R writes to the console. */\nexport interface BuiltNote {\n readonly element: HTMLElement;\n /** Show a note, or take the line away when there is none. */\n show(text: string | null): void;\n}\n\n/**\n * Correct a starting value to something the slider can stand at.\n *\n * Three rules, in order, taken from the `validate()` of the\n * `ion.rangeSlider.js` that ships inside shiny. A value that is not a number\n * becomes the minimum; a value outside the range moves to the nearer bound; a\n * value that misses the step moves to the nearest step, counted from the\n * minimum.\n *\n * The third rule is not R's — R leaves the handle wherever it was asked to\n * stand — but an HTML range input rounds a step-mismatched value by itself,\n * so a component that kept the asked-for number would draw one picture and\n * show a slider standing at another.\n *\n * @param given The value the caller asked for, or nothing.\n * @param fallback The value R's own argument defaults to.\n * @param range Where the slider may stand.\n * @returns A value on the slider's own grid.\n */\nexport function startingSliderValue(\n given: number | undefined,\n fallback: number,\n range: SliderRange,\n): number {\n if (given === undefined) {\n return fallback;\n }\n if (!Number.isFinite(given)) {\n return range.min;\n }\n\n const clamped = Math.min(range.max, Math.max(range.min, given));\n // Scaling both sides by the step's own precision keeps a value that sits\n // exactly halfway from rounding the wrong way: 1.25 is 32.5 steps above a\n // minimum of −2, and 3.25 / 0.1 alone lands a hair below that.\n const decimals = decimalsOf(range.step);\n const factor = 10 ** decimals;\n const steps = Math.round(\n ((clamped - range.min) * factor) / (range.step * factor),\n );\n const snapped = Number((range.min + steps * range.step).toFixed(decimals));\n // Every range in this port has its maximum on the step grid, so this only\n // guards a range that does not.\n return Math.min(range.max, snapped);\n}\n\n/** Return how many decimals a step carries. */\nfunction decimalsOf(step: number): number {\n return String(step).split(\".\")[1]?.length ?? 0;\n}\n\n/**\n * Build one labeled slider that shows its own value.\n *\n * @param owner The document to build in.\n * @param name The name the component reads the event by.\n * @param label R's own caption.\n * @param range Where the slider may stand.\n * @param value Where it starts. Pass a value `startingSliderValue` returned.\n * @returns The wrapper to append, the input to listen to, and the readout.\n */\nexport function buildSlider(\n owner: Document,\n name: string,\n label: string,\n range: SliderRange,\n value: number,\n): BuiltSlider {\n const wrapper = owner.createElement(\"label\");\n wrapper.style.display = \"block\";\n\n const caption = owner.createElement(\"span\");\n caption.textContent = `${label} `;\n\n const readout = owner.createElement(\"output\");\n readout.textContent = String(value);\n\n const input = owner.createElement(\"input\");\n input.type = \"range\";\n input.name = name;\n input.min = String(range.min);\n input.max = String(range.max);\n input.step = String(range.step);\n input.value = String(value);\n input.style.width = \"100%\";\n\n wrapper.appendChild(caption);\n wrapper.appendChild(readout);\n wrapper.appendChild(input);\n return { wrapper, input, readout };\n}\n\n/**\n * Build one labeled picker.\n *\n * @param owner The document to build in.\n * @param name The name the component reads the event by.\n * @param label R's own caption.\n * @param choices The options, in the order R lists them. A numeric choice\n * reaches the DOM as its own text, which is how R's own numeric choices\n * arrive there.\n * @param selected The option to start on.\n * @returns The wrapper to append, and the input to listen to.\n */\nexport function buildSelect(\n owner: Document,\n name: string,\n label: string,\n choices: readonly (string | number)[],\n selected: string | number,\n): BuiltSelect {\n const wrapper = owner.createElement(\"label\");\n wrapper.style.display = \"block\";\n\n const caption = owner.createElement(\"span\");\n caption.textContent = `${label} `;\n\n const input = owner.createElement(\"select\");\n input.name = name;\n input.style.width = \"100%\";\n for (const choice of choices) {\n const option = owner.createElement(\"option\");\n option.value = String(choice);\n option.textContent = String(choice);\n input.appendChild(option);\n }\n input.value = String(selected);\n\n wrapper.appendChild(caption);\n wrapper.appendChild(input);\n return { wrapper, input };\n}\n\n/**\n * Build the line that carries what R writes to the console.\n *\n * A library cannot write to a console, and the plot layer therefore returns\n * its message instead of printing it. One element, whose text is replaced,\n * so that a hundred redraws leave one sentence rather than a hundred.\n *\n * @param owner The document to build in.\n * @returns The element to append, and the way to set its text.\n */\nexport function buildNote(owner: Document): BuiltNote {\n const element = owner.createElement(\"p\");\n element.style.margin = \"4px 0 0\";\n element.style.fontSize = \"12px\";\n element.textContent = \"\";\n element.hidden = true;\n\n return {\n element,\n show(text: string | null): void {\n element.textContent = text ?? \"\";\n element.hidden = text === null;\n },\n };\n}\n",
|
|
9
9
|
"/**\n * The drawing surface that every 2D plot writes to.\n *\n * R's base graphics draw to a current device. Nothing here does: a plot\n * function receives its target and draws only to that target.\n *\n * `Context2D` lists the exact members of `CanvasRenderingContext2D` that this\n * library uses. A real context satisfies the type, and a test can pass any\n * object that implements those members. This matters because happy-dom has no\n * 2D canvas context, so a DOM alone cannot exercise a plot function. See\n * `test/recording-context.ts` for the stub the plot tests use.\n */\n\n/** The part of a canvas 2D context that the plot functions draw through. */\nexport type Context2D = Pick<\n CanvasRenderingContext2D,\n | \"fillStyle\"\n | \"strokeStyle\"\n | \"lineWidth\"\n | \"font\"\n | \"textAlign\"\n | \"textBaseline\"\n | \"save\"\n | \"restore\"\n | \"beginPath\"\n | \"moveTo\"\n | \"lineTo\"\n | \"arc\"\n | \"rect\"\n | \"fillRect\"\n | \"clip\"\n | \"fill\"\n | \"stroke\"\n | \"fillText\"\n | \"setLineDash\"\n | \"translate\"\n | \"rotate\"\n>;\n\n/** A context together with the pixel size of its surface. */\nexport interface RenderTarget {\n readonly ctx: Context2D;\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * What a plot function accepts.\n *\n * Pass a canvas in a browser. Pass a `RenderTarget` to draw through your own\n * context, which is how the tests run without a DOM.\n */\nexport type PlotTarget = HTMLCanvasElement | RenderTarget;\n\n/**\n * Reduce a plot target to a context and a size.\n *\n * A canvas reports the size of its pixel store, which is the size the plot\n * draws in. On a dense screen those two part company: the store has to hold\n * more pixels than the layout does, or the browser stretches the image and\n * softens every edge.\n *\n * This function never touches a canvas the caller passed in — the caller owns\n * it, and resizing it under them would throw away whatever else they drew. So\n * a caller who wants a crisp picture on such a screen does three things:\n *\n * 1. size the store at the layout size times `devicePixelRatio`, and set the\n * CSS width and height to the layout size;\n * 2. call `ctx.scale(ratio, ratio)` once, so drawing carries on in layout\n * pixels;\n * 3. pass `{ ctx, width, height }` with the **layout** size, rather than the\n * canvas.\n *\n * The third step matters. Handing over the canvas would report the store size\n * on top of a context that already scales, and the picture would come out at\n * the square of the ratio. Reporting layout pixels also keeps `eventPixel`\n * right, since it divides the surface size by the size of the client\n * rectangle. `resolveControlTarget` in `../interactive/target.ts` does all\n * three for the canvas it builds itself.\n */\nexport function resolveTarget(target: PlotTarget): RenderTarget {\n if (\"ctx\" in target) {\n return target;\n }\n const ctx = target.getContext(\"2d\");\n if (ctx === null) {\n throw new Error(\n \"plot target: the canvas gave no 2D context. In tests, pass \" +\n \"{ ctx, width, height } instead of a canvas element.\",\n );\n }\n return { ctx, width: target.width, height: target.height };\n}\n",
|
|
10
10
|
"/**\n * The target that every interactive component attaches to.\n *\n * An interactive component needs two things: a surface to draw on and an\n * element that reports the clicks. A canvas is both, so a browser caller\n * passes one canvas.\n *\n * A test cannot pass a canvas. happy-dom gives a canvas no 2D context, so\n * nothing can draw to it. A test therefore passes the two things apart: a\n * recording surface to draw to, and a real element to dispatch events at. This\n * split is the pattern for every module in `src/interactive/`.\n */\n\nimport { resolveTarget } from \"../plot/target\";\nimport type { RenderTarget } from \"../plot/target\";\n\n/** The part of an element that an interactive component listens to. */\nexport type ClickSource = Pick<\n HTMLElement,\n \"addEventListener\" | \"removeEventListener\" | \"getBoundingClientRect\"\n>;\n\n/** A surface and an element, held apart. */\nexport interface SplitTarget {\n /** Where the component draws. */\n readonly surface: RenderTarget;\n /** Where the component listens. */\n readonly element: ClickSource;\n}\n\n/** What an interactive component accepts. */\nexport type InteractiveTarget = HTMLCanvasElement | SplitTarget;\n\n/**\n * Reduce an interactive target to a surface and an element.\n *\n * @param target A canvas, or a surface and an element.\n * @returns The two parts.\n * @throws Error If a canvas gives no 2D context.\n */\nexport function resolveInteractiveTarget(\n target: InteractiveTarget,\n): SplitTarget {\n if (\"surface\" in target) {\n return target;\n }\n return { surface: resolveTarget(target), element: target };\n}\n\n/**\n * Convert the position of a mouse event to a pixel of the surface.\n *\n * CSS may show a canvas at a size other than its pixel size. The function\n * therefore scales the position by the ratio of the two. A rectangle of zero\n * width or height carries no ratio, so the function reads the client position\n * as a surface pixel. Only a hidden element and a stub report such a\n * rectangle.\n *\n * @param element The element that received the event.\n * @param surface The drawing surface and its pixel size.\n * @param event The mouse event.\n * @returns The pixel column and row of the event.\n */\nexport function eventPixel(\n element: ClickSource,\n surface: RenderTarget,\n event: MouseEvent,\n): { readonly x: number; readonly y: number } {\n const rect = element.getBoundingClientRect();\n const scaleX = rect.width === 0 ? 1 : surface.width / rect.width;\n const scaleY = rect.height === 0 ? 1 : surface.height / rect.height;\n return {\n x: (event.clientX - rect.left) * scaleX,\n y: (event.clientY - rect.top) * scaleY,\n };\n}\n\n/**\n * A drawing surface and an element to build controls in, held apart.\n *\n * This is the `SplitTarget` idea again, for a component driven by a panel of\n * controls rather than by clicks on the picture. A test passes the two parts,\n * so it can drive the inputs without a real layout and without a canvas that\n * happy-dom cannot give a context to.\n */\nexport interface PanelTarget {\n /** Where the component draws. */\n readonly surface: RenderTarget;\n /** Where the component builds its inputs. The caller keeps this element. */\n readonly controls: HTMLElement;\n}\n\n/**\n * What a control-driven component accepts.\n *\n * Pass a container element in a browser and the component fills it. Pass a\n * `PanelTarget` to hold the two parts apart, which is how the tests run.\n */\nexport type ControlTarget = HTMLElement | PanelTarget;\n\n/** A resolved panel, and a way to take back anything that was built for it. */\nexport interface ResolvedPanel {\n readonly surface: RenderTarget;\n readonly controls: HTMLElement;\n /** Remove what this resolver created. A no-op when the caller supplied it. */\n release(): void;\n}\n\n/** R lays the gadget out as a 140px column of controls beside the plot. */\nconst CONTROL_COLUMN_WIDTH = 140;\nconst FALLBACK_WIDTH = 640;\nconst FALLBACK_HEIGHT = 400;\n\n/**\n * Reduce a control target to a surface and a place to build controls.\n *\n * Given a container, this builds the canvas and the controls column inside it\n * in R's arrangement, and `release()` takes them out again. Given the parts,\n * it passes them through and `release()` does nothing, because the caller owns\n * what it supplied.\n *\n * @param target A container element, or a surface and a controls host.\n * @returns The two parts and a way to undo what was built.\n * @throws Error If a container is a canvas, or if a created canvas gives no 2D\n * context.\n */\nexport function resolveControlTarget(target: ControlTarget): ResolvedPanel {\n if (\"surface\" in target) {\n return {\n surface: target.surface,\n controls: target.controls,\n release: () => undefined,\n };\n }\n\n if (target.tagName === \"CANVAS\") {\n throw new Error(\n \"interactive target: pass a container element to build the panel in, \" +\n \"not a canvas. A canvas has no room for the controls.\",\n );\n }\n\n const owner = target.ownerDocument;\n const controls = owner.createElement(\"div\");\n controls.style.width = `${CONTROL_COLUMN_WIDTH}px`;\n controls.style.flexShrink = \"0\";\n controls.style.padding = \"4px 6px\";\n controls.style.overflowY = \"auto\";\n\n const width =\n target.clientWidth > CONTROL_COLUMN_WIDTH\n ? target.clientWidth - CONTROL_COLUMN_WIDTH\n : FALLBACK_WIDTH;\n const height =\n target.clientHeight > 0 ? target.clientHeight : FALLBACK_HEIGHT;\n const ratio = pixelRatio();\n\n // The store holds one pixel per device pixel; the style keeps the element\n // the size the layout asked for. Without this the browser stretches a\n // smaller image over a denser screen and every edge, letters worst of all,\n // comes out soft.\n const canvas = owner.createElement(\"canvas\");\n canvas.width = Math.round(width * ratio);\n canvas.height = Math.round(height * ratio);\n canvas.style.width = `${width}px`;\n canvas.style.height = `${height}px`;\n canvas.style.minWidth = \"0\";\n\n target.style.display = \"flex\";\n target.appendChild(controls);\n target.appendChild(canvas);\n\n const remove = (): void => {\n controls.remove();\n canvas.remove();\n };\n\n const context = canvas.getContext(\"2d\");\n if (context === null) {\n // Leave the container as it was found rather than half filled.\n remove();\n throw new Error(\n \"interactive target: the canvas gave no 2D context. In tests, pass \" +\n \"{ surface: { ctx, width, height }, controls } instead of a container.\",\n );\n }\n\n // Scale once, here, so that everything drawn afterwards keeps working in\n // layout pixels and knows nothing about the density of the screen.\n if (ratio !== 1) {\n context.scale(ratio, ratio);\n }\n\n return { surface: { ctx: context, width, height }, controls, release: remove };\n}\n\n/**\n * An element for Plotly to fill, and an element to build controls in.\n *\n * The third target shape of the port, after `SplitTarget` and `PanelTarget`.\n * The 3D components need it because Plotly draws into an element of its own\n * rather than onto a canvas: there is no context to hand around, and the\n * element the plot lives in is the element the engine later purges.\n */\nexport interface Plot3dPanel {\n /** Where Plotly draws. The component gives this element to the plot. */\n readonly plot: HTMLElement;\n /** Where the component builds its inputs. */\n readonly controls: HTMLElement;\n}\n\n/**\n * What a 3D component accepts.\n *\n * Pass a container element in a browser and the component fills it. Pass the\n * two parts to hold them apart, which is how the tests run.\n */\nexport type Plot3dTarget = HTMLElement | Plot3dPanel;\n\n/** A resolved 3D panel, and a way to take back anything built for it. */\nexport interface ResolvedPlot3dPanel extends Plot3dPanel {\n /** Remove what this resolver created. A no-op when the caller supplied it. */\n release(): void;\n}\n\n/** The height a plot element falls back to when the container declares none. */\nconst FALLBACK_PLOT_HEIGHT = 480;\n\n/**\n * Reduce a 3D target to a plot element and a place to build controls.\n *\n * Given a container, this builds the two elements in R's own arrangement: a\n * strip of controls across the top, and the plot filling what is left. R's\n * gadget lays both 3D families out that way (`flex-direction: column`, the\n * control rows `flex-shrink: 0`, the plot `flex: 1`).\n *\n * @param target A container element, or the two parts.\n * @returns The two parts and a way to undo what was built.\n * @throws Error If a container is a canvas, which Plotly cannot draw into.\n */\nexport function resolvePlot3dTarget(target: Plot3dTarget): ResolvedPlot3dPanel {\n if (\"plot\" in target) {\n return {\n plot: target.plot,\n controls: target.controls,\n release: () => undefined,\n };\n }\n\n if (target.tagName === \"CANVAS\") {\n throw new Error(\n \"interactive target: pass a container element to build the panel in, \" +\n \"not a canvas. Plotly draws into an element of its own.\",\n );\n }\n\n const owner = target.ownerDocument;\n const controls = owner.createElement(\"div\");\n controls.style.display = \"flex\";\n controls.style.flexWrap = \"wrap\";\n controls.style.gap = \"12px\";\n controls.style.padding = \"8px\";\n controls.style.flexShrink = \"0\";\n\n const plot = owner.createElement(\"div\");\n plot.style.flex = \"1 1 auto\";\n plot.style.minHeight =\n target.clientHeight > 0 ? \"0\" : `${FALLBACK_PLOT_HEIGHT}px`;\n\n target.style.display = \"flex\";\n target.style.flexDirection = \"column\";\n target.appendChild(controls);\n target.appendChild(plot);\n\n return {\n plot,\n controls,\n release: () => {\n controls.remove();\n plot.remove();\n },\n };\n}\n\n/**\n * How many device pixels the screen puts in a layout pixel.\n *\n * Anything other than a positive number, which is what a test environment\n * without a screen reports, counts as one.\n */\nfunction pixelRatio(): number {\n const ratio = globalThis.devicePixelRatio;\n return typeof ratio === \"number\" && ratio > 0 ? ratio : 1;\n}\n",
|
|
11
11
|
"/**\n * The interactive 3D scatterplot: choose the columns, set the style, turn the\n * cloud, and take the resulting call away with you.\n *\n * This is the port of `interactive_scatter3d()` in\n * `../compstatslib/R/scatter3d_interactive.R`. R builds a shiny gadget with\n * four pickers and five sliders and re-runs `plot_scatter3d()` on every\n * change. This module does the same: it owns the controls, the state in them,\n * and the camera the user turned to, and hands every draw to `plotScatter3d`.\n * It builds no trace and no layout of its own.\n *\n * Four things are worth knowing before reading the code.\n *\n * **Everything is checked before anything is built.** R validates the style,\n * then the axis arguments, then the frame, and only then opens the gadget, so\n * a bad argument leaves no window and no plot. The order and the wording here\n * are R's, and the style check is R's own function, imported from the plot\n * layer rather than written again.\n *\n * **Out of range is not the same as invalid.** R's check refuses a style no\n * plot could be drawn with — an opacity of 0, a negative aspect — and says\n * nothing about the bounds of its own sliders. `aspect = 12` passes it, and\n * the widget then clamps the handle to 10. So this component throws exactly\n * where R throws, and clamps and snaps where R's widget clamps.\n *\n * **The camera is captured, not computed.** Plotly reports where the user\n * turned the plot to through `plotly_relayout`; the component stores that\n * camera and re-passes it into every later draw, so that changing a column\n * does not throw the angle away. Turning the plot draws nothing: Plotly has\n * already moved the picture. The captured camera is also written back into\n * Plotly's own stored layout, because the modebar's buttons relayout the\n * scene from that layout and would otherwise snap the view to the default —\n * a Plotly quirk the R gadget shares, and one deliberate deviation here.\n *\n * **Done hands back a state, not a printed call.** R prints a copy-pasteable\n * `plot_scatter3d(...)` line to the console and returns the same arguments\n * invisibly. A library has no console, and a string would have to be parsed\n * to be used again; so `getValues()` returns the options object that\n * reproduces the picture, and `onDone` receives it. Feeding it back to\n * `plotScatter3d` — or to this function — is R's `do.call` equivalent.\n *\n * One R behavior is absent for R's own reason: the gadget shows no message\n * about the column choice. `plot_scatter3d()` writes one when it picks the\n * columns itself, and neither gadget lets it: R passes `input$x`, `input$y`\n * and `input$z` on every render, as this component passes its own state. The\n * choice is visible in the pickers instead.\n */\n\nimport { numericColumns, requireThreeNumericColumns } from \"../core/frame\";\nimport type { DataFrame } from \"../core/frame\";\nimport {\n DEFAULT_SCATTER3D_STYLE,\n plotScatter3d,\n validateScatter3dStyle,\n} from \"../plot/scatter3d\";\nimport type {\n PlotScatter3dOptions,\n Scatter3dSpec,\n Scatter3dSpecOptions,\n} from \"../plot/scatter3d\";\nimport { sameCamera } from \"../plot/plotly\";\nimport type {\n PlotlyHTMLElement,\n PlotlyLike,\n PlotlyRelayoutEvent,\n} from \"../plot/plotly\";\nimport {\n buildNote,\n buildSelect,\n buildSlider,\n startingSliderValue,\n} from \"./controls\";\nimport type { SliderRange } from \"./controls\";\nimport { resolvePlot3dTarget } from \"./target\";\nimport type { Plot3dTarget } from \"./target\";\n\n/**\n * Everything the panel holds, and everything that reproduces the picture.\n *\n * This is `Scatter3dSpecOptions` with the parts the gadget always settles —\n * the three axes and the three style numbers — made certain. Hand it to\n * `plotScatter3d`, or back to `interactiveScatter3d`, to open at the same\n * view. It is the port's answer to the call R prints on Done.\n */\nexport interface Scatter3dValues extends Scatter3dSpecOptions {\n /** The column on the first horizontal axis. */\n readonly x: string;\n /** The column on the second horizontal axis. */\n readonly y: string;\n /** The column on the vertical axis. */\n readonly z: string;\n /** The three axis proportions. */\n readonly aspect: readonly number[];\n /** How solid each marker is. */\n readonly opacity: number;\n /** How large each marker is. */\n readonly size: number;\n}\n\n/**\n * What the component accepts.\n *\n * Every option of `plotScatter3d` is a starting value, exactly as in R, and\n * anything the plot grows later reaches it untouched.\n */\nexport interface InteractiveScatter3dOptions extends PlotScatter3dOptions {\n /** What to run on `done()`. */\n readonly onDone?: (values: Scatter3dValues) => void;\n}\n\n/** What the caller holds after the component starts. */\nexport interface InteractiveScatter3dHandle {\n /**\n * Return the state the panel stands at: the options that reproduce the\n * picture, including a camera the user turned to.\n */\n getValues(): Scatter3dValues;\n /**\n * Return what the last draw specified — its traces, its layout, and the\n * plot layer's note. Null until the first picture is drawn.\n */\n getSpec(): Scatter3dSpec | null;\n /**\n * Wait for the drawing now in flight. Drawing is asynchronous, so this is\n * how a caller — or a test — knows the picture is on the screen.\n */\n rendered(): Promise<void>;\n /** Hand the current state to the `onDone` callback. */\n done(): void;\n /** Stop listening, purge the plot, and take back what was built. */\n destroy(): void;\n}\n\n/** R's `choices = c(\"(none)\", names(data))` sentinel for no color. */\nconst NONE = \"(none)\";\n\n/** R: `sliderInput(\"aspect_x\", \"Aspect X\", min = 0.1, max = 10, step = .1)`. */\nconst ASPECT_RANGE: SliderRange = { min: 0.1, max: 10, step: 0.1 };\n/** R: `sliderInput(\"opacity\", \"Opacity\", min = 0.05, max = 1, step = 0.05)`. */\nconst OPACITY_RANGE: SliderRange = { min: 0.05, max: 1, step: 0.05 };\n/** R: `sliderInput(\"size\", \"Size\", min = 1, max = 20, step = 1)`. */\nconst SIZE_RANGE: SliderRange = { min: 1, max: 20, step: 1 };\n\n/** The three aspect sliders, in R's order, with the axis each one drives. */\nconst ASPECT_SLIDERS = [\n { name: \"aspectX\", label: \"Aspect X\" },\n { name: \"aspectY\", label: \"Aspect Y\" },\n { name: \"aspectZ\", label: \"Aspect Z\" },\n] as const;\n\n/**\n * Start an interactive 3D scatterplot on a target.\n *\n * The component builds its controls, draws once, and redraws on every change.\n *\n * @param target A container element, or a plot element and a controls host.\n * See `./target.ts`.\n * @param data The frame to read. It needs three numeric columns.\n * @param options Starting values, a done callback, and the options of\n * `plotScatter3d`.\n * @returns The handle to the running component. Await `rendered()` for the\n * first picture.\n * @throws RangeError If the style is one no plot could be drawn with, if the\n * frame has fewer than three numeric columns, or if an initial column is\n * not one the picker could stand on. Nothing is built and nothing is drawn\n * in any of those cases.\n * @throws Error If a canvas is passed as the container.\n */\nexport function interactiveScatter3d(\n target: Plot3dTarget,\n data: DataFrame,\n options: InteractiveScatter3dOptions = {},\n): InteractiveScatter3dHandle {\n // Everything `plotScatter3d` may grow later stays in `forwarded` and\n // reaches it untouched, so a new plot option needs no edit here.\n const {\n plotly: givenEngine,\n onDone,\n x,\n y,\n z,\n color,\n aspect,\n opacity,\n size,\n camera,\n titles,\n ...forwarded\n } = options;\n\n // R's order, and R's own check: the style first of all.\n const style = {\n aspect: aspect ?? DEFAULT_SCATTER3D_STYLE.aspect,\n opacity: opacity ?? DEFAULT_SCATTER3D_STYLE.opacity,\n size: size ?? DEFAULT_SCATTER3D_STYLE.size,\n };\n validateScatter3dStyle(style.aspect, style.opacity, style.size);\n\n const numeric = numericColumns(data);\n requireThreeNumericColumns(numeric, \"interactiveScatter3d\");\n for (const [axis, given] of [\n [\"x\", x],\n [\"y\", y],\n [\"z\", z],\n ] as const) {\n if (given !== undefined && !numeric.includes(given)) {\n throw new RangeError(\n `Initial \\`${axis}\\` (\"${given}\") is not a numeric column of ` +\n `\\`data\\`. Numeric columns: ${numeric.join(\", \")}.`,\n );\n }\n }\n if (color !== undefined && data[color] === undefined) {\n throw new RangeError(`Initial \\`color\\` (\"${color}\") is not in \\`data\\`.`);\n }\n\n const panel = resolvePlot3dTarget(target);\n const owner = panel.controls.ownerDocument;\n\n let values: Scatter3dValues = {\n x: x ?? numeric[0],\n y: y ?? numeric[1],\n z: z ?? numeric[2],\n color,\n aspect: style.aspect.map((value, axis) =>\n startingSliderValue(\n value,\n DEFAULT_SCATTER3D_STYLE.aspect[axis],\n ASPECT_RANGE,\n ),\n ),\n opacity: startingSliderValue(\n style.opacity,\n DEFAULT_SCATTER3D_STYLE.opacity,\n OPACITY_RANGE,\n ),\n size: startingSliderValue(\n style.size,\n DEFAULT_SCATTER3D_STYLE.size,\n SIZE_RANGE,\n ),\n camera,\n titles,\n };\n\n let spec: Scatter3dSpec | null = null;\n let engine: PlotlyLike | undefined = givenEngine;\n let element: PlotlyHTMLElement | null = null;\n let listening = false;\n let destroyed = false;\n let inFlight: Promise<void> | null = null;\n let queued = false;\n\n const note = buildNote(owner);\n\n /**\n * Draw once, at whatever the panel stands at now.\n *\n * The engine is resolved by the first draw and held afterwards, so a\n * component loads Plotly once however often it redraws.\n */\n async function renderOnce(): Promise<void> {\n const drawn = await plotScatter3d(panel.plot, data, {\n ...forwarded,\n ...values,\n plotly: engine,\n });\n if (destroyed) {\n return;\n }\n\n engine = drawn.plotly;\n element = drawn.element;\n spec = { traces: drawn.traces, layout: drawn.layout, note: drawn.note };\n note.show(drawn.note);\n\n // One listener for the life of the component: Plotly hands back the same\n // element every time, so attaching per draw would pile them up.\n if (!listening) {\n listening = true;\n element.on(\"plotly_relayout\", handleRelayout);\n }\n }\n\n /**\n * Draw, and never draw twice at once.\n *\n * A dragged slider fires an event for every step, and each draw is\n * asynchronous. Overlapping draws could reach the engine out of order and\n * leave the picture at a value the user has already left. So a request that\n * arrives while a draw is in flight is remembered, not started, and the\n * draw that follows reads the state as it stands then: the last value\n * always wins, and one draw is in flight at a time.\n */\n function requestRender(): void {\n if (destroyed) {\n return;\n }\n queued = true;\n inFlight ??= start();\n }\n\n function start(): Promise<void> {\n const run = pump();\n // A caller that never awaits must not be handed an unhandled rejection;\n // `rendered()` still reports the failure to anyone who asks.\n run.catch(() => undefined);\n return run;\n }\n\n async function pump(): Promise<void> {\n try {\n while (queued && !destroyed) {\n queued = false;\n await renderOnce();\n }\n } finally {\n inFlight = null;\n }\n }\n\n /**\n * R's observer: store the camera, and leave the picture alone — with one\n * addition R does not need. Plotly's own modebar buttons (orbit, turntable,\n * pan, zoom) relayout the scene from the stored layout, and a dragged\n * camera lives only in the WebGL scene until it is written back; without\n * the push below, every modebar click snapped the view to the default. The\n * push itself echoes through this handler with the same camera as a fresh\n * object, which is what the value comparison recognizes and drops.\n */\n function handleRelayout(event: PlotlyRelayoutEvent): void {\n const moved = event[\"scene.camera\"];\n if (moved === undefined || destroyed || sameCamera(moved, values.camera)) {\n return;\n }\n values = { ...values, camera: moved };\n if (element !== null && engine !== undefined) {\n // Fire and forget: the picture is already at this view, so a failure\n // here (a plot purged mid-flight) has nothing to repair.\n engine.relayout(element, { \"scene.camera\": moved }).catch(() => undefined);\n }\n }\n\n function handleChange(event: Event): void {\n const input = event.target as HTMLSelectElement;\n if (input.name === \"color\") {\n values = {\n ...values,\n color: input.value === NONE ? undefined : input.value,\n };\n } else {\n values = { ...values, [input.name]: input.value };\n }\n requestRender();\n }\n\n function handleInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n // A slider keeps its own value inside the range and on the step, so what\n // it reports needs no correcting.\n const moved = Number(input.value);\n const axis = ASPECT_SLIDERS.findIndex(\n (slider) => slider.name === input.name,\n );\n if (axis >= 0) {\n values = {\n ...values,\n aspect: values.aspect.map((was, index) =>\n index === axis ? moved : was,\n ),\n };\n } else {\n values = { ...values, [input.name]: moved };\n }\n\n const readout = readouts.get(input.name);\n if (readout !== undefined) {\n readout.textContent = input.value;\n }\n requestRender();\n }\n\n const built: HTMLElement[] = [];\n const selects: HTMLSelectElement[] = [];\n const sliders: HTMLInputElement[] = [];\n const readouts = new Map<string, HTMLElement>();\n\n for (const [axis, label] of [\n [\"x\", \"X\"],\n [\"y\", \"Y\"],\n [\"z\", \"Z\"],\n ] as const) {\n const picker = buildSelect(owner, axis, label, numeric, values[axis]);\n panel.controls.appendChild(picker.wrapper);\n built.push(picker.wrapper);\n selects.push(picker.input);\n }\n\n const colorPicker = buildSelect(\n owner,\n \"color\",\n \"Color\",\n [NONE, ...Object.keys(data)],\n values.color ?? NONE,\n );\n panel.controls.appendChild(colorPicker.wrapper);\n built.push(colorPicker.wrapper);\n selects.push(colorPicker.input);\n\n for (const [axis, wanted] of ASPECT_SLIDERS.entries()) {\n const control = buildSlider(\n owner,\n wanted.name,\n wanted.label,\n ASPECT_RANGE,\n values.aspect[axis],\n );\n panel.controls.appendChild(control.wrapper);\n built.push(control.wrapper);\n sliders.push(control.input);\n readouts.set(wanted.name, control.readout);\n }\n\n for (const [name, label, range, value] of [\n [\"opacity\", \"Opacity\", OPACITY_RANGE, values.opacity],\n [\"size\", \"Size\", SIZE_RANGE, values.size],\n ] as const) {\n const control = buildSlider(owner, name, label, range, value);\n panel.controls.appendChild(control.wrapper);\n built.push(control.wrapper);\n sliders.push(control.input);\n readouts.set(name, control.readout);\n }\n\n panel.controls.appendChild(note.element);\n built.push(note.element);\n\n for (const select of selects) {\n select.addEventListener(\"change\", handleChange);\n }\n for (const slider of sliders) {\n slider.addEventListener(\"input\", handleInput);\n }\n\n // R's renderPlot runs as the gadget opens, at the initial settings.\n requestRender();\n\n /** A copy deep enough that a caller cannot reach back into the state. */\n function currentValues(): Scatter3dValues {\n return { ...values, aspect: [...values.aspect] };\n }\n\n return {\n getValues: currentValues,\n getSpec: () => spec,\n rendered: () => inFlight ?? Promise.resolve(),\n done() {\n onDone?.(currentValues());\n },\n destroy() {\n if (destroyed) {\n return;\n }\n destroyed = true;\n for (const select of selects) {\n select.removeEventListener(\"change\", handleChange);\n }\n for (const slider of sliders) {\n slider.removeEventListener(\"input\", handleInput);\n }\n for (const node of built) {\n node.remove();\n }\n if (element !== null) {\n element.removeAllListeners(\"plotly_relayout\");\n engine?.purge(element);\n }\n panel.release();\n },\n };\n}\n",
|
|
12
|
-
"/**\n * Shared array arithmetic for the core modules.\n *\n * Use these helpers with `map` instead of index-based loops. See the\n * iteration convention in CLAUDE.md.\n */\n\n/** Add all values. Return 0 for an empty array. */\nexport function sum(values: readonly number[]): number {\n return values.reduce((total, value) => total + value, 0);\n}\n\n/** Return the arithmetic mean. Return NaN for an empty array. */\nexport function mean(values: readonly number[]): number {\n return sum(values) / values.length;\n}\n\n/**\n * Return the smallest and the largest value, as R's `range()` does.\n *\n * Written as a fold rather than `Math.min(...values)`, which overflows the\n * call stack on a long column.\n *\n * @param values The observations.\n * @returns The lowest and the highest value. An empty array returns\n * [Infinity, -Infinity], the shape of R's `range(numeric(0))`.\n *\n * A comparison keeps the accumulator when it is false, so a NaN entry is\n * skipped rather than carried through. No caller supports NaN input: the\n * modules that call this either drop the non-finite values first or state\n * that they do not handle R's NA.\n */\nexport function extent(values: readonly number[]): [number, number] {\n return values.reduce<[number, number]>(\n ([low, high], value) => [\n value < low ? value : low,\n value > high ? value : high,\n ],\n [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY],\n );\n}\n\n/**\n * Map a negative zero to a positive one.\n *\n * A computed zero can come out of an algorithm with a sign that R's own\n * zeros never carry: of 1498 zero entries of a matrix inverse over a sweep of\n * 20000 slider settings, R gives a positive zero every time.\n */\nexport function withoutNegativeZero(value: number): number {\n return value === 0 ? 0 : value;\n}\n\n/** Reject a count that is not a non-negative integer. */\nexport function requireCount(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative integer, got ${value}`);\n }\n}\n\n/**\n * Combine two arrays element by element.\n *\n * Stop at the end of the shorter array.\n */\nexport function zipWith<A, B, C>(\n as: readonly A[],\n bs: readonly B[],\n combine: (a: A, b: B) => C,\n): C[] {\n const length = Math.min(as.length, bs.length);\n // The slice bounds the index, so the access cannot be undefined.\n return as.slice(0, length).map((a, index) => combine(a, bs[index] as B));\n}\n\n/**\n * Return the standard deviation, with the n − 1 denominator of R's `sd()`.\n *\n * @param values The observations.\n * @returns The standard deviation, or NaN below two values. R returns NA\n * there, with a warning that a library cannot give.\n */\nexport function sd(values: readonly number[]): number {\n if (values.length < 2) {\n return Number.NaN;\n }\n\n const center = mean(values);\n const squares = values.map((value) => (value - center) * (value - center));\n return Math.sqrt(sum(squares) / (values.length - 1));\n}\n\n/**\n * Return the mean absolute deviation, `mean(|x - mean(x)|)`.\n *\n * R base has no function for this. R's `mad()` is the *median* absolute\n * deviation from the median, scaled by 1.4826, which is a different\n * statistic. A caller that shows either one to a reader must write the name\n * in full, because the abbreviation covers both.\n *\n * The sampling demonstration offers this as one of its choices of statistic.\n * It measures spread in the units of the data, as the standard deviation\n * does, but a value far from the mean moves it less, because the distance is\n * not squared.\n *\n * @param values The observations.\n * @returns The mean distance from the mean. One value gives 0, because it\n * sits at its own mean. No values gives NaN, as `mean` does.\n */\nexport function meanAbsoluteDeviation(values: readonly number[]): number {\n const center = mean(values);\n return mean(values.map((value) => Math.abs(value - center)));\n}\n\n/**\n * Return `a * b + c`, rounded once.\n *\n * Written as `a * b + c`, JavaScript rounds twice — once for the product,\n * once for the sum — and the two roundings show. R's `seq.int` rounds once\n * and lands one unit in the last place away often enough to change a tick.\n * The linear algebra in `matrix.ts` needs the same: the compiler of the R\n * install the fixtures come from contracts a multiply and an add into one\n * instruction, so a matrix near singular differs in every digit without it.\n *\n * The two helpers below split each operation into the value a double can\n * hold plus the part it drops, so the dropped parts can be added back before\n * the one rounding that remains. Both are the standard error-free\n * transformations (Dekker 1971, Knuth). Both need every intermediate to stay\n * in range, which fails only within a factor of 2^28 of the largest double.\n * There the plain form is used: the result is already dominated by its own\n * overflow.\n */\nexport function fusedMultiplyAdd(a: number, b: number, c: number): number {\n const [product, productError] = twoProduct(a, b);\n const [sum, sumError] = twoSum(c, product);\n const rounded = sum + (sumError + productError);\n return Number.isFinite(rounded) ? rounded : a * b + c;\n}\n\n/** Split a double into two halves whose product is exact. Dekker's method. */\nfunction split(value: number): [number, number] {\n const scaled = 134217729 * value;\n const high = scaled - (scaled - value);\n return [high, value - high];\n}\n\n/** Return the product and the part of it the product cannot hold. */\nfunction twoProduct(a: number, b: number): [number, number] {\n const product = a * b;\n const [aHigh, aLow] = split(a);\n const [bHigh, bLow] = split(b);\n const error =\n aLow * bLow - (product - aHigh * bHigh - aLow * bHigh - aHigh * bLow);\n return [product, error];\n}\n\n/** Return the sum and the part of it the sum cannot hold. */\nfunction twoSum(a: number, b: number): [number, number] {\n const sum = a + b;\n const carried = sum - a;\n return [sum, a - (sum - carried) + (b - carried)];\n}\n\n/**\n * Return a sample quantile, by the rule of R's `quantile(type = 7)`.\n *\n * Type 7 is the default of R's `quantile()`, and so the rule behind the\n * `IQR()` that `bw.nrd0()` uses to pick a bandwidth. It reads the sorted\n * values at position `1 + (n - 1) * p` and interpolates between the two\n * neighbors of a fractional position.\n *\n * @param values The observations. The function does not modify them.\n * @param p The probability. It must be in [0, 1].\n * @returns The quantile, or NaN for no values. R returns NA there.\n * @throws RangeError If p is outside [0, 1], as R does.\n */\nexport function quantile(values: readonly number[], p: number): number {\n return quantiles(values, [p])[0] as number;\n}\n\n/**\n * Return several sample quantiles, by the rule of R's `quantile(type = 7)`.\n *\n * R's `quantile()` also takes a vector of probabilities, and for one reason:\n * it sorts once and reads every position off the one sorted copy. Asking for\n * the two quartiles together instead of one at a time halves the work, which\n * is what the bandwidth rule does over a pooled sample.\n *\n * @param values The observations. The function does not modify them.\n * @param probs The probabilities. Each must be in [0, 1].\n * @returns One quantile per probability, in the order given. Each is NaN for\n * no values, where R returns NA.\n * @throws RangeError If a probability is outside [0, 1], as R does.\n */\nexport function quantiles(\n values: readonly number[],\n probs: readonly number[],\n): number[] {\n if (probs.some((p) => !(p >= 0 && p <= 1))) {\n throw new RangeError(`every probability must be in [0, 1], got ${probs}`);\n }\n if (values.length === 0) {\n return probs.map(() => Number.NaN);\n }\n\n // A Float64Array sorts by value with no comparator to call, which is about\n // three times faster than sorting a copy of the array over a pooled sample.\n const sorted = Float64Array.from(values).sort();\n\n return probs.map((p) => type7(sorted, p));\n}\n\n/**\n * Return the median, the value with half the observations on each side.\n *\n * R's `median()` sorts the values and, on an even count, averages the two in\n * the middle. That is the type-7 quantile at 0.5, which weights those same two\n * values by a half each, so this delegates rather than repeat the rule. The\n * two forms land on the same double, the halves included.\n *\n * The sampling demonstration offers this as one of its choices of statistic.\n * It marks the center in the units of the data, as the mean does, but a value\n * far from the center moves it very little, because only the ordering counts.\n *\n * @param values The observations. The function does not modify them.\n * @returns The median, or NaN for no values. R returns NA there.\n */\nexport function median(values: readonly number[]): number {\n return quantile(values, 0.5);\n}\n\n/** Read one type-7 quantile off already sorted values. */\nfunction type7(sorted: Float64Array, p: number): number {\n const position = 1 + (sorted.length - 1) * p;\n const below = Math.floor(position);\n const above = Math.ceil(position);\n // Both indices are inside the array: p in [0, 1] bounds the position by\n // 1 and by the length.\n const low = sorted[below - 1] as number;\n const high = sorted[above - 1] as number;\n\n if (position > below && high !== low) {\n // R's own form. The algebraically equal low + h * (high - low) rounds\n // differently, and this keeps the last bits with R.\n const h = position - below;\n return (1 - h) * low + h * high;\n }\n return low;\n}\n",
|
|
13
|
-
"/**\n * Dense (weighted) least squares for small designs.\n *\n * This is the equivalent of R's `lm.wfit()`, and of the solver R runs inside\n * every step of `glm.fit()`'s IRLS loop. R factors the design with `dqrdc2`,\n * a Householder QR with a limited column-pivoting rule: a column whose norm\n * has collapsed against the columns to its left is moved to the right edge\n * and its coefficient is reported as `NA`. The port reproduces that rule,\n * because it is what makes `lm()` and `glm()` report an aliased coefficient\n * instead of dividing by a near-zero pivot. Verified against R in\n * `ols.test.ts`.\n *\n * Designs here are tiny — two columns for logit, four for a moderation\n * surface — so the code follows the LINPACK routine plainly rather than\n * blocking or vectorizing it.\n */\n\nimport { sum, zipWith } from \"./arith\";\n\n/**\n * The result of a fit.\n *\n * A `null` coefficient is the equivalent of R's `NA`: the column carried no\n * information beyond the columns to its left, so R aliases it. `linearRegression`\n * uses the same convention.\n */\nexport interface LeastSquaresFit {\n /**\n * One coefficient per design column, in column order. An aliased column\n * reports null.\n */\n readonly coefficients: readonly (number | null)[];\n /** The fitted response of each row, in input order. */\n readonly fitted: readonly number[];\n /** Response minus fit, of each row, in input order. */\n readonly residuals: readonly number[];\n /** The number of columns the fit could identify. */\n readonly rank: number;\n}\n\nexport interface LeastSquaresOptions {\n /**\n * One weight per row, on R's `lm.wfit()` scale: the solver applies the\n * square root itself.\n *\n * IRLS is the trap here. `glm.fit` carries square-root weights `w` and\n * hands `x * w` to its QR routine, so a caller porting that loop passes\n * `w * w` here, not `w`.\n *\n * A weight of zero drops the row from the fit. The row still gets a fitted\n * value, predicted from the other rows, as it does in R.\n */\n readonly weights?: readonly number[];\n /**\n * How far a column's norm may collapse before the fit aliases it.\n *\n * A column is aliased when its norm, after the columns to its left are\n * projected out, falls below this fraction of its original norm. The\n * default is the value `lm.fit()` uses. `glm.fit()` passes\n * `min(1e-7, epsilon / 1000)`, which is `1e-11` at R's default epsilon.\n */\n readonly tolerance?: number;\n}\n\n/** The rank tolerance of R's `lm.fit()`. */\nexport const DEFAULT_LEAST_SQUARES_TOLERANCE = 1e-7;\n\n/**\n * Fit `y` on the columns of `design` by least squares.\n *\n * @param design One row per observation, each row one value per column. A\n * model with an intercept carries a leading column of ones. The function\n * does not modify it.\n * @param y The response, one value per row.\n * @param options Weights and the rank tolerance.\n * @returns The coefficients, the fit, and the rank.\n * @throws RangeError if there are no rows, if the shapes disagree, or if a\n * weight is negative. R refuses the same inputs: \"0 (non-NA) cases\" and\n * \"missing or negative weights not allowed\".\n */\nexport function leastSquares(\n design: readonly (readonly number[])[],\n y: readonly number[],\n options: LeastSquaresOptions = {},\n): LeastSquaresFit {\n const { weights, tolerance = DEFAULT_LEAST_SQUARES_TOLERANCE } = options;\n const rows = design.length;\n\n if (rows === 0) {\n throw new RangeError(\"least squares needs at least one row\");\n }\n const width = design[0].length;\n if (design.some((row) => row.length !== width)) {\n throw new RangeError(\"every design row needs the same number of columns\");\n }\n if (y.length !== rows) {\n throw new RangeError(\n `the response has ${y.length} values but the design has ${rows} rows`,\n );\n }\n if (weights !== undefined) {\n if (weights.length !== rows) {\n throw new RangeError(\n `there are ${weights.length} weights but ${rows} rows`,\n );\n }\n if (weights.some((weight) => !(weight >= 0))) {\n throw new RangeError(\"weights cannot be negative or missing\");\n }\n }\n\n // Scale each row by the square root of its weight, which turns the weighted\n // problem into an ordinary one. This is what lm.wfit and glm.fit both do.\n const scale = weights?.map((weight) => Math.sqrt(weight));\n const scaled = (value: number, row: number): number =>\n scale === undefined ? value : value * scale[row];\n\n const columns = Array.from({ length: width }, (_, column) =>\n design.map((row, index) => scaled(row[column], index)),\n );\n const projected = y.map(scaled);\n\n const { householders, pivot, rank } = decompose(columns, tolerance, rows);\n applyHouseholders(columns, householders, projected, Math.min(rank, rows - 1));\n const solved = backSubstitute(columns, projected, rank);\n\n // The solve returns the coefficients in pivot order. An aliased column\n // never reaches the solve and keeps its null, the way R reports NA.\n const coefficients = new Array<number | null>(width).fill(null);\n pivot.slice(0, rank).forEach((column, position) => {\n coefficients[column] = solved[position];\n });\n\n const fitted = design.map((row) =>\n sum(\n zipWith(row, coefficients, (value, coefficient) =>\n coefficient === null ? 0 : value * coefficient,\n ),\n ),\n );\n const residuals = zipWith(y, fitted, (value, fit) => value - fit);\n\n return { coefficients, fitted, residuals, rank };\n}\n\n/**\n * Factor the columns in place, R's way.\n *\n * `dqrdc2` walks the columns left to right. A column whose remaining norm has\n * fallen below `tolerance` times its original norm moves to the right edge and\n * the columns behind it shift left, so the columns that survive keep their\n * original order — which is why R can report the coefficients of a rank-\n * deficient fit in their own slots, with `NA` in the slot of the column it\n * dropped.\n *\n * On return each column holds its part of R above the diagonal and the\n * Householder vector below it, as LINPACK stores them.\n *\n * @returns The Householder scalars, the column order, and the rank.\n */\nfunction decompose(\n columns: number[][],\n tolerance: number,\n rows: number,\n): { householders: number[]; pivot: number[]; rank: number } {\n const width = columns.length;\n const pivot = columns.map((_, column) => column);\n // R substitutes 1 for a zero norm, so that an all-zero column compares as\n // negligible rather than dividing by zero.\n const originalNorms = columns.map((column) => norm(column, 0) || 1);\n const householders = new Array<number>(width).fill(0);\n // The count of columns still in play. R keeps this as `k` and rank is\n // min(k, rows) once the walk is over.\n let live = width;\n\n // Index loops throughout: a QR factorization addresses single matrix\n // entries by position, and this one follows LINPACK's dqrdc2 step for step.\n for (let step = 0; step < Math.min(rows, width); step++) {\n while (\n step < live &&\n norm(columns[step], step) < originalNorms[step] * tolerance\n ) {\n cycleToEnd(columns, pivot, originalNorms, step);\n live -= 1;\n }\n\n // The last row leaves nothing to reflect. R skips it and keeps the entry\n // as it stands, which is how a design with more columns than rows still\n // resolves the coefficients it can.\n if (step === rows - 1) {\n continue;\n }\n householders[step] = reflect(columns, step, rows);\n }\n\n return { householders, pivot, rank: Math.min(live, rows) };\n}\n\n/**\n * Build the Householder reflector of one column and apply it to the columns\n * to its right.\n *\n * @returns The leading entry of the reflector, which R keeps in `qraux`.\n */\nfunction reflect(columns: number[][], step: number, rows: number): number {\n const column = columns[step];\n const length = norm(column, step);\n if (length === 0) {\n return 0;\n }\n // Reflect away from the leading entry, so that nothing cancels.\n const pivotNorm = column[step] < 0 ? -length : length;\n\n for (let row = step; row < rows; row++) {\n column[row] = column[row] / pivotNorm;\n }\n const leading = 1 + column[step];\n column[step] = leading;\n\n for (let index = step + 1; index < columns.length; index++) {\n const other = columns[index];\n let inner = 0;\n for (let row = step; row < rows; row++) {\n inner += column[row] * other[row];\n }\n const factor = -inner / leading;\n for (let row = step; row < rows; row++) {\n other[row] = other[row] + factor * column[row];\n }\n }\n\n column[step] = -pivotNorm;\n return leading;\n}\n\n/** Apply the stored reflectors to the response, giving Qᵀy. */\nfunction applyHouseholders(\n columns: readonly number[][],\n householders: readonly number[],\n response: number[],\n count: number,\n): void {\n const rows = response.length;\n\n for (let step = 0; step < count; step++) {\n const leading = householders[step];\n if (leading === 0) {\n continue;\n }\n const column = columns[step];\n // The reflector's leading entry lives outside the column, so the two\n // passes below read it separately from the entries under the diagonal.\n let inner = leading * response[step];\n for (let row = step + 1; row < rows; row++) {\n inner += column[row] * response[row];\n }\n const factor = -inner / leading;\n response[step] = response[step] + factor * leading;\n for (let row = step + 1; row < rows; row++) {\n response[row] = response[row] + factor * column[row];\n }\n }\n}\n\n/** Solve the leading `rank` columns of the triangular system. */\nfunction backSubstitute(\n columns: readonly number[][],\n response: readonly number[],\n rank: number,\n): number[] {\n const solved = new Array<number>(rank).fill(0);\n\n for (let row = rank - 1; row >= 0; row--) {\n let value = response[row];\n for (let column = row + 1; column < rank; column++) {\n value -= columns[column][row] * solved[column];\n }\n solved[row] = value / columns[row][row];\n }\n\n return solved;\n}\n\n/** Move one column to the right edge, sliding the rest left. */\nfunction cycleToEnd(\n columns: number[][],\n pivot: number[],\n originalNorms: number[],\n step: number,\n): void {\n moveToEnd(columns, step);\n moveToEnd(pivot, step);\n moveToEnd(originalNorms, step);\n}\n\n/** Move one entry of an array to its end, sliding the rest left. */\nfunction moveToEnd<T>(track: T[], from: number): void {\n const [moved] = track.splice(from, 1) as [T];\n track.push(moved);\n}\n\n/** The Euclidean length of a column from `from` down. */\nfunction norm(column: readonly number[], from: number): number {\n return Math.hypot(...column.slice(from));\n}\n",
|
|
14
|
-
"/**\n * The fitted surface of a moderated regression.\n *\n * This is the statistics half of `plot_moderation_3d()` in the R package,\n * which fits `lm(formula, data)`, predicts over a 15 by 15 grid of the IV and\n * the moderator, and hands the grid to `lattice::wireframe()`. Verified\n * against R in `moderation.test.ts`.\n *\n * Four things are worth knowing before reading the code.\n *\n * **Columns, not a formula.** R names the model with `y ~ x * z`. TypeScript\n * has no such notation, so the model arrives as column names, per CLAUDE.md:\n * an outcome, an IV, a moderator, an optional list of controls, and a flag\n * for the interaction. The three models the fixtures pin are\n * `{outcome: \"y\", iv: \"x\", mod: \"z\"}` (R's `y ~ x * z`), the same with\n * `interaction: false` (`y ~ x + z`), and the same with `controls: [\"w\"]`\n * (`y ~ x + z + w + x:z`).\n *\n * **The design follows R's model matrix, not the option order.** R's\n * `model.matrix` puts every main effect before any interaction, whatever\n * order the formula was typed in, so `y ~ x + z + w + x:z` gives the columns\n * `(Intercept), x, z, w, x:z`. This module builds them in that order, which\n * is what lets a caller read the coefficients next to R's.\n *\n * **Controls are held at their mean, and only numbers are accepted.** R's\n * `hold_value()` also handles factors (first level), characters (first in\n * sort order) and logicals (always FALSE). The bundled data has no such\n * column and no doc example uses one, so this port supports the numeric\n * branch alone and refuses the rest, rather than shipping three rules nothing\n * exercises. The other rules are recorded in\n * `.claude/plans/moderation-fixtures.md` section 4 if they are ever wanted.\n *\n * **Missing values leave the fit, as R's do.** `lm()` drops incomplete rows\n * through `na.omit` and `hold_value()` averages with `na.rm = TRUE`; this\n * port does the same, with NaN standing in for `NA` and any non-finite value\n * counting as missing. The details — the `na.exclude`-style NaN padding of\n * `fitted` and `residuals`, the one departure on `zlim` — are on\n * `moderationSurface` itself.\n */\n\nimport { extent, mean, sum, zipWith } from \"./arith\";\nimport { frameRows, requireNumericColumn, type DataFrame } from \"./frame\";\nimport { leastSquares } from \"./ols\";\n\n/**\n * The number of steps along each axis of the grid. R's\n * `plot_moderation_3d()` hardcodes `length.out = 15` for both.\n */\nconst GRID_STEPS = 15;\n\n/** Which columns make the model. */\nexport interface ModerationOptions {\n /** The column to predict — the vertical axis of the surface. */\n readonly outcome: string;\n /** The predictor on the first horizontal axis. */\n readonly iv: string;\n /** The predictor on the second horizontal axis. */\n readonly mod: string;\n /**\n * Whether the model carries the IV by moderator product. True by default,\n * which is R's `y ~ x * z`. False gives R's additive `y ~ x + z`, whose\n * surface is a plane with no twist.\n */\n readonly interaction?: boolean;\n /**\n * Further predictors to fit but not to plot. Each is held at its own mean\n * over the grid, R's `hold_value()` for a numeric column. Empty by default.\n */\n readonly controls?: readonly string[];\n}\n\n/** One fitted term, named as R names it. */\nexport interface ModerationTerm {\n /**\n * R's coefficient name: `(Intercept)`, a column name, or `iv:mod` for the\n * product term.\n */\n readonly name: string;\n /**\n * The coefficient, or null where R reports `NA` — a column the fit could\n * not tell apart from the columns before it.\n */\n readonly value: number | null;\n}\n\n/** A fitted model and the surface it predicts. */\nexport interface ModerationSurface {\n /** The fitted terms, in R's model-matrix order. */\n readonly coefficients: readonly ModerationTerm[];\n /**\n * The fitted outcome of each data row, in input order. NaN where the row\n * was dropped for a missing value, as R's `na.exclude` pads.\n */\n readonly fitted: readonly number[];\n /**\n * The outcome minus the fit, of each data row, in input order. NaN where\n * the row was dropped for a missing value.\n */\n readonly residuals: readonly number[];\n /** The 15 IV values of the grid, from the column's minimum to its maximum. */\n readonly ivValues: readonly number[];\n /** The 15 moderator values of the grid, over the same span. */\n readonly modValues: readonly number[];\n /**\n * The 225 predicted outcomes, **with the IV varying fastest**: index\n * `j * 15 + i` holds the prediction at `ivValues[i]` and `modValues[j]`.\n * This is the row order of R's `expand.grid(seq_iv, seq_mod)`.\n */\n readonly predictions: readonly number[];\n /**\n * The vertical range to draw, as `[low, high]`: the range of the observed\n * outcome together with the range of the surface. Which of the two reaches\n * further depends on the model — an interaction usually swings the surface\n * past the data at the corners of the grid, while a plane stays inside it.\n */\n readonly zlim: readonly [number, number];\n /** The value each control is held at over the grid: its mean. */\n readonly holds: Readonly<Record<string, number>>;\n}\n\n/**\n * Fit the model and predict its surface.\n *\n * Rows with a missing (non-finite) value in any model column are dropped\n * before fitting, R's `na.action = na.omit`; their fitted values and\n * residuals report NaN, keeping input order. The grid and zlim span the\n * finite values of their columns, and a control is held at its finite mean —\n * R's `hold_value()` with `na.rm = TRUE`. (R itself computes zlim with no\n * `na.rm` and fails on a missing outcome; the port draws what it can fit, a\n * stated departure.)\n *\n * @param data The frame holding every column the options name.\n * @param options Which column plays which part in the model.\n * @returns The fit, the grid, the surface, and the vertical range.\n * @throws RangeError If a named column is absent, empty, or not numeric, if\n * the IV and the moderator are the same column, if a control repeats\n * another named column, if the frame is ragged, or if no row is complete.\n */\nexport function moderationSurface(\n data: DataFrame,\n options: ModerationOptions,\n): ModerationSurface {\n const { outcome, iv, mod, interaction = true, controls = [] } = options;\n\n if (iv === mod) {\n throw new RangeError(\n `\\`iv\\` and \\`mod\\` must name different columns, both name \"${iv}\"`,\n );\n }\n // A repeated column would enter the design twice and alias itself, and the\n // caller would read a null coefficient with no clue why.\n const named = new Set([outcome, iv, mod]);\n controls.forEach((control) => {\n if (named.has(control)) {\n throw new RangeError(\n `control \"${control}\" already names the outcome, the iv, the mod, ` +\n \"or another control\",\n );\n }\n named.add(control);\n });\n\n const rows = frameRows(data);\n const y = requireNumericColumn(data, outcome, \"outcome\");\n const ivColumn = requireNumericColumn(data, iv, \"iv\");\n const modColumn = requireNumericColumn(data, mod, \"mod\");\n const controlColumns = controls.map((control) =>\n requireNumericColumn(data, control, \"controls\"),\n );\n\n // R's na.omit: a row with a missing value in any model column leaves the\n // fit. NaN is this library's missing value, and an infinity would poison\n // the fit the same way, so \"complete\" means finite everywhere.\n const modelColumns = [y, ivColumn, modColumn, ...controlColumns];\n const completeRows = y\n .map((_, row) => row)\n .filter((row) =>\n modelColumns.every((column) => Number.isFinite(column[row])),\n );\n if (completeRows.length === 0) {\n throw new RangeError(\n \"the model has no complete rows: every row is missing a value in \" +\n \"the outcome, the IV, the moderator, or a control\",\n );\n }\n\n // R's model.matrix order: the intercept, the main effects in the order the\n // model names them, then the interaction.\n const designColumns: readonly {\n readonly name: string;\n readonly values: readonly number[];\n }[] = [\n { name: \"(Intercept)\", values: new Array<number>(rows).fill(1) },\n { name: iv, values: ivColumn },\n { name: mod, values: modColumn },\n ...controls.map((control, index) => ({\n name: control,\n values: controlColumns[index] as readonly number[],\n })),\n ...(interaction\n ? [\n {\n name: `${iv}:${mod}`,\n values: zipWith(ivColumn, modColumn, (a, b) => a * b),\n },\n ]\n : []),\n ];\n\n const design = completeRows.map((row) =>\n designColumns.map((column) => column.values[row] as number),\n );\n const fit = leastSquares(\n design,\n completeRows.map((row) => y[row] as number),\n );\n const coefficients = designColumns.map((column, index) => ({\n name: column.name,\n value: fit.coefficients[index] ?? null,\n }));\n\n // R's na.exclude padding: report the fit in input order, NaN where a row\n // was dropped.\n const fitted = new Array<number>(rows).fill(Number.NaN);\n const residuals = new Array<number>(rows).fill(Number.NaN);\n completeRows.forEach((row, survivor) => {\n fitted[row] = fit.fitted[survivor] as number;\n residuals[row] = fit.residuals[survivor] as number;\n });\n\n // extent() ignores non-finite values, so each axis spans its column's\n // finite range — R's seq over min and max, which R only reaches when the\n // column has no NA. The hold is R's hold_value(): mean with na.rm = TRUE.\n const ivValues = rSeq(...extent(ivColumn), GRID_STEPS);\n const modValues = rSeq(...extent(modColumn), GRID_STEPS);\n const holds = Object.fromEntries(\n controls.map((control, index) => [\n control,\n mean(\n (controlColumns[index] as readonly number[]).filter(Number.isFinite),\n ),\n ]),\n );\n\n // R's predict() drops an aliased term rather than giving up on the row, so\n // a null coefficient contributes nothing here either.\n const weights = coefficients.map((term) => term.value ?? 0);\n const predictions = modValues.flatMap((modValue) =>\n ivValues.map((ivValue) => {\n const gridRow = [\n 1,\n ivValue,\n modValue,\n ...controls.map((control) => holds[control] as number),\n ...(interaction ? [ivValue * modValue] : []),\n ];\n return sum(zipWith(gridRow, weights, (value, weight) => value * weight));\n }),\n );\n\n const [dataLow, dataHigh] = extent(y);\n const [surfaceLow, surfaceHigh] = extent(predictions);\n\n return {\n coefficients,\n fitted,\n residuals,\n ivValues,\n modValues,\n predictions,\n zlim: [Math.min(dataLow, surfaceLow), Math.max(dataHigh, surfaceHigh)],\n holds,\n };\n}\n\n/**\n * Step from one end of a span to the other, the way R's\n * `seq(from, to, length.out = n)` does.\n *\n * R computes `from + i * by` in plain double arithmetic and writes both\n * endpoints in exactly. That last part matters — it is why the grid always\n * reaches the data's own minimum and maximum — and so does the plain\n * arithmetic: rounding the product and the sum together, as `pretty.ts` must\n * for R's other sequence path, moves 14 of the 30 grid coordinates of the\n * bundled dataset off R's values.\n *\n * @param from The first value.\n * @param to The last value.\n * @param length How many values to return.\n * @returns The sequence. A span of no width repeats its one value, as R's\n * `seq(3, 3, length.out = 15)` does.\n */\nfunction rSeq(from: number, to: number, length: number): number[] {\n if (from === to) {\n return new Array<number>(length).fill(from);\n }\n\n const by = (to - from) / (length - 1);\n return Array.from({ length }, (_, index) =>\n index === 0 ? from : index === length - 1 ? to : from + index * by,\n );\n}\n",
|
|
15
|
-
"/**\n * The moderation surface: a fitted regression drawn as a height field over\n * the IV and the moderator.\n *\n * This is the drawing half of `plot_moderation_3d()` of\n * `../compstatslib/R/moderation_3d_plot.R`. Every number comes from\n * `moderationSurface` in `src/core/moderation.ts`; this module computes no\n * statistics of its own. The grid values are pinned in\n * `.claude/plans/moderation-fixtures.md` section 3.\n *\n * Three decisions are worth stating.\n *\n * **The engine is Plotly, not lattice.** R draws this surface with\n * `lattice::wireframe(drape = TRUE, colorkey = FALSE)`, which colors the mesh\n * by height and hides the key. A Plotly surface is colored by height already,\n * so the port sets `showscale: false` and keeps the rest. The colors\n * themselves are Plotly's, not lattice's: a browser has no lattice palette,\n * and the teaching point of the picture is the twist of the surface, not its\n * hue.\n *\n * **The rotation arguments become a camera, approximately.** Lattice takes\n * `screen = list(z = z_rot, x = x_rot)`, two rotations of the data. Plotly\n * takes a camera position. `cameraFromRotations` maps one onto the other, and\n * says how.\n *\n * **The vertical axis carries the outcome.** With the bundled data the\n * moderator is named `z` and it is drawn on a horizontal axis, while the\n * outcome `y` stands up. R's help makes the same point, twice.\n */\n\nimport { moderationSurface } from \"../core/moderation\";\nimport type { ModerationOptions, ModerationSurface } from \"../core/moderation\";\nimport type { DataFrame } from \"../core/frame\";\nimport { loadPlotly } from \"./plotly\";\nimport type {\n EyeCamera,\n PlotlyHTMLElement,\n PlotlyLayout,\n PlotlyLike,\n SurfaceTrace,\n Vector3,\n} from \"./plotly\";\n\n/** R's `z_rot = 40`: the turn about the vertical axis, in degrees. */\nconst DEFAULT_Z_ROT = 40;\n/** R's `x_rot = -70`: the tilt, in degrees. */\nconst DEFAULT_X_ROT = -70;\n/**\n * How far the camera stands from the middle of the scene. This is the length\n * of Plotly's own default eye, `(1.25, 1.25, 1.25)`, so a plot that sets a\n * camera opens at the same distance as one that does not.\n */\nconst EYE_DISTANCE = 1.25 * Math.sqrt(3);\n/** The name Plotly keeps the view under, across every redraw. */\nconst UIREVISION = \"moderation3d\";\n/** Plotly redraws the plot when the element that holds it changes size. */\nconst CONFIG = { responsive: true } as const;\n\n/** How to look at the surface. */\nexport interface Moderation3dViewOptions {\n /**\n * The turn about the vertical axis, in degrees. R's `z_rot`, 40 by default.\n * 0 lays the IV across the screen; 270 lays the moderator across it.\n */\n readonly zRot?: number;\n /**\n * The tilt, in degrees. R's `x_rot`, −70 by default. −90 looks along the\n * floor of the plot, and the view rises towards 0.\n */\n readonly xRot?: number;\n /**\n * The values the vertical axis spans, as `[low, high]`. The range of the\n * data together with the range of the surface by default, which is R's own\n * rule and what `moderationSurface` reports as `zlim`.\n */\n readonly zlim?: readonly [number, number];\n}\n\n/** The options of `plotModeration3d`: the model, the view, and the engine. */\nexport interface PlotModeration3dOptions\n extends ModerationOptions,\n Moderation3dViewOptions {\n /**\n * The Plotly engine. `loadPlotly()` by default, which fetches the library on\n * first use.\n */\n readonly plotly?: PlotlyLike;\n}\n\n/** What a surface and a set of view options draw. */\nexport interface Moderation3dSpec {\n /** The one height field. */\n readonly traces: readonly SurfaceTrace[];\n readonly layout: PlotlyLayout;\n /**\n * What R says in its `message()` when predictors are held off the axes.\n * Null when every predictor of the model is drawn.\n */\n readonly note: string | null;\n}\n\n/** A drawn surface: its specification, its fit, its element, and its engine. */\nexport interface Moderation3dHandle extends Moderation3dSpec {\n /** The element Plotly drew into, with its event emitter attached. */\n readonly element: PlotlyHTMLElement;\n /** The engine that drew, ready for the next redraw and for teardown. */\n readonly plotly: PlotlyLike;\n /** The fit and the grid behind the picture. */\n readonly surface: ModerationSurface;\n}\n\n/**\n * Place the camera for a pair of lattice rotations.\n *\n * This is a visual approximation, not an equivalence: lattice rotates the data\n * and Plotly moves the camera, and the two pictures agree in direction, not\n * pixel for pixel. The mapping is\n *\n * ```text\n * azimuth = -90 - zRot degrees\n * elevation = 90 + xRot degrees\n * eye = distance * (cos elevation * cos azimuth,\n * cos elevation * sin azimuth,\n * sin elevation)\n * ```\n *\n * Both anchors of R's own help hold under it. At `zRot = 0` the camera stands\n * on the moderator axis, so the IV runs across the screen and the IV slope\n * plane faces the viewer; at `zRot = 270` the camera stands on the IV axis and\n * the moderator plane faces it. The tilt reads the same way as lattice's: at\n * `xRot = -90` the camera is level with the floor of the plot, and R's default\n * −70 lifts it 20 degrees above it.\n *\n * @param zRot The turn about the vertical axis, in degrees.\n * @param xRot The tilt, in degrees.\n * @returns The camera, as Plotly's `scene.camera`.\n * @throws RangeError If either angle is not a finite number, which would\n * place the camera nowhere.\n */\nexport function cameraFromRotations(zRot: number, xRot: number): EyeCamera {\n if (!Number.isFinite(zRot) || !Number.isFinite(xRot)) {\n throw new RangeError(\"`zRot` and `xRot` must be finite numbers.\");\n }\n\n const azimuth = ((-90 - zRot) * Math.PI) / 180;\n const elevation = ((90 + xRot) * Math.PI) / 180;\n const eye: Vector3 = {\n x: EYE_DISTANCE * Math.cos(elevation) * Math.cos(azimuth),\n y: EYE_DISTANCE * Math.cos(elevation) * Math.sin(azimuth),\n z: EYE_DISTANCE * Math.sin(elevation),\n };\n\n return { eye };\n}\n\n/**\n * Build the trace and the layout of a moderation surface.\n *\n * @param surface The fit and the grid, from `moderationSurface`.\n * @param model The columns the surface was fitted over. Their names title the\n * axes, and the controls decide whether there is a note.\n * @param view How to look at the surface.\n * @returns The trace, the layout, and the note about held predictors.\n * @throws RangeError If a rotation is not finite, if a given vertical range is\n * not two finite numbers, or if any height of the surface is not finite —\n * a non-finite height would crash the WebGL engine for the whole page.\n */\nexport function moderation3dSpec(\n surface: ModerationSurface,\n model: ModerationOptions,\n view: Moderation3dViewOptions = {},\n): Moderation3dSpec {\n const { zRot = DEFAULT_Z_ROT, xRot = DEFAULT_X_ROT, zlim } = view;\n const camera = cameraFromRotations(zRot, xRot);\n\n if (zlim !== undefined) {\n if (zlim.length !== 2 || !zlim.every((value) => Number.isFinite(value))) {\n throw new RangeError(\"`zlim` must be two finite numbers.\");\n }\n }\n const range: readonly [number, number] = zlim ?? [\n surface.zlim[0],\n surface.zlim[1],\n ];\n\n // Plotly reads a height field row by row along y, so each row of z holds one\n // moderator value and runs across the IV. That is R's own grid order, the IV\n // varying fastest: index j * 15 + i.\n const steps = surface.ivValues.length;\n const heights = surface.modValues.map((_, j) =>\n surface.ivValues.map((__, i) => surface.predictions[j * steps + i] as number),\n );\n\n // A NaN in the height field does not fail politely: it crashes WebGL inside\n // plotly.js, and every surface drawn on the page afterwards fails too.\n // Refuse here so that no caller can poison the engine.\n if (!surface.predictions.every(Number.isFinite)) {\n throw new RangeError(\n \"the surface must have finite heights everywhere; \" +\n \"a prediction is NaN or infinite\",\n );\n }\n\n const trace: SurfaceTrace = {\n type: \"surface\",\n x: surface.ivValues,\n y: surface.modValues,\n z: heights,\n // R's `colorkey = FALSE`.\n showscale: false,\n };\n\n const layout: PlotlyLayout = {\n uirevision: UIREVISION,\n scene: {\n xaxis: { title: { text: model.iv } },\n yaxis: { title: { text: model.mod } },\n zaxis: { title: { text: model.outcome }, range },\n uirevision: UIREVISION,\n camera,\n },\n };\n\n return { traces: [trace], layout, note: describeHolds(model) };\n}\n\n/**\n * Fit the model and draw its surface.\n *\n * @param target The element to draw into. Plotly fills it.\n * @param data The frame holding every column the model names.\n * @param options The model, the view, and the engine.\n * @returns The drawn plot: its element, its specification, its engine, and the\n * surface behind it.\n * @throws RangeError Everything `moderationSurface` and `moderation3dSpec`\n * throw, as a rejected promise. Nothing reaches the engine until the model\n * is fitted and the view is settled.\n */\nexport async function plotModeration3d(\n target: HTMLElement,\n data: DataFrame,\n options: PlotModeration3dOptions,\n): Promise<Moderation3dHandle> {\n const { plotly, zRot, xRot, zlim, ...model } = options;\n const surface = moderationSurface(data, model);\n const spec = moderation3dSpec(surface, model, { zRot, xRot, zlim });\n const engine = plotly ?? (await loadPlotly());\n const element = await engine.react(target, spec.traces, spec.layout, CONFIG);\n\n return { ...spec, element, plotly: engine, surface };\n}\n\n/** R's `describe_holds()`: one sentence, and only when a predictor is held. */\nfunction describeHolds(model: ModerationOptions): string | null {\n if ((model.controls ?? []).length === 0) {\n return null;\n }\n return (\n `Surface shows predicted ${model.outcome} over ${model.iv} and ` +\n `${model.mod}. Other predictors are held at their typical values.`\n );\n}\n",
|
|
12
|
+
"/**\n * Shared array arithmetic for the core modules.\n *\n * Use these helpers with `map` instead of index-based loops. See the\n * iteration convention in CLAUDE.md.\n */\n\n/** Add all values. Return 0 for an empty array. */\nexport function sum(values: readonly number[]): number {\n return values.reduce((total, value) => total + value, 0);\n}\n\n/** Return the arithmetic mean. Return NaN for an empty array. */\nexport function mean(values: readonly number[]): number {\n return sum(values) / values.length;\n}\n\n/**\n * Return the smallest and the largest value, as R's `range()` does.\n *\n * Written as a fold rather than `Math.min(...values)`, which overflows the\n * call stack on a long column.\n *\n * @param values The observations.\n * @returns The lowest and the highest value. An empty array returns\n * [Infinity, -Infinity], the shape of R's `range(numeric(0))`.\n *\n * A comparison keeps the accumulator when it is false, so a NaN entry is\n * skipped rather than carried through. No caller supports NaN input: the\n * modules that call this either drop the non-finite values first or state\n * that they do not handle R's NA.\n */\nexport function extent(values: readonly number[]): [number, number] {\n return values.reduce<[number, number]>(\n ([low, high], value) => [\n value < low ? value : low,\n value > high ? value : high,\n ],\n [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY],\n );\n}\n\n/**\n * Map a negative zero to a positive one.\n *\n * A computed zero can come out of an algorithm with a sign that R's own\n * zeros never carry: of 1498 zero entries of a matrix inverse over a sweep of\n * 20000 slider settings, R gives a positive zero every time.\n */\nexport function withoutNegativeZero(value: number): number {\n return value === 0 ? 0 : value;\n}\n\n/** Reject a count that is not a non-negative integer. */\nexport function requireCount(value: number, name: string): void {\n if (!Number.isInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative integer, got ${value}`);\n }\n}\n\n/**\n * Combine two arrays element by element.\n *\n * Stop at the end of the shorter array.\n */\nexport function zipWith<A, B, C>(\n as: readonly A[],\n bs: readonly B[],\n combine: (a: A, b: B) => C,\n): C[] {\n const length = Math.min(as.length, bs.length);\n // The slice bounds the index, so the access cannot be undefined.\n return as.slice(0, length).map((a, index) => combine(a, bs[index] as B));\n}\n\n/**\n * Return the standard deviation, with the n − 1 denominator of R's `sd()`.\n *\n * @param values The observations.\n * @returns The standard deviation, or NaN below two values. R returns NA\n * there, with a warning that a library cannot give.\n */\nexport function sd(values: readonly number[]): number {\n if (values.length < 2) {\n return Number.NaN;\n }\n\n const center = mean(values);\n const squares = values.map((value) => (value - center) * (value - center));\n return Math.sqrt(sum(squares) / (values.length - 1));\n}\n\n/**\n * Return the mean absolute deviation, `mean(|x - mean(x)|)`.\n *\n * R base has no function for this. R's `mad()` is the *median* absolute\n * deviation from the median, scaled by 1.4826, which is a different\n * statistic. A caller that shows either one to a reader must write the name\n * in full, because the abbreviation covers both.\n *\n * The sampling demonstration offers this as one of its choices of statistic.\n * It measures spread in the units of the data, as the standard deviation\n * does, but a value far from the mean moves it less, because the distance is\n * not squared.\n *\n * @param values The observations.\n * @returns The mean distance from the mean. One value gives 0, because it\n * sits at its own mean. No values gives NaN, as `mean` does.\n */\nexport function meanAbsoluteDeviation(values: readonly number[]): number {\n const center = mean(values);\n return mean(values.map((value) => Math.abs(value - center)));\n}\n\n/**\n * Return `a * b + c`, rounded once.\n *\n * Written as `a * b + c`, JavaScript rounds twice — once for the product,\n * once for the sum — and the two roundings show. R's `seq.int` rounds once\n * and lands one unit in the last place away often enough to change a tick.\n * The linear algebra in `matrix.ts` needs the same: the compiler of the R\n * install the fixtures come from contracts a multiply and an add into one\n * instruction, so a matrix near singular differs in every digit without it.\n *\n * The two helpers below split each operation into the value a double can\n * hold plus the part it drops, so the dropped parts can be added back before\n * the one rounding that remains. Both are the standard error-free\n * transformations (Dekker 1971, Knuth). Both need every intermediate to stay\n * in range, which fails only within a factor of 2^28 of the largest double.\n * There the plain form is used: the result is already dominated by its own\n * overflow.\n */\nexport function fusedMultiplyAdd(a: number, b: number, c: number): number {\n // A zero product adds exactly, and only the plain form keeps the sign of\n // a zero sum the way the hardware instruction does: fma(-1, 0, -0) is -0.\n if (a * b === 0) {\n return c + a * b;\n }\n const [product, productError] = twoProduct(a, b);\n const [sum, sumError] = twoSum(c, product);\n const rounded = sum + (sumError + productError);\n return Number.isFinite(rounded) ? rounded : a * b + c;\n}\n\n/** Split a double into two halves whose product is exact. Dekker's method. */\nfunction split(value: number): [number, number] {\n const scaled = 134217729 * value;\n const high = scaled - (scaled - value);\n return [high, value - high];\n}\n\n/** Return the product and the part of it the product cannot hold. */\nfunction twoProduct(a: number, b: number): [number, number] {\n const product = a * b;\n const [aHigh, aLow] = split(a);\n const [bHigh, bLow] = split(b);\n const error =\n aLow * bLow - (product - aHigh * bHigh - aLow * bHigh - aHigh * bLow);\n return [product, error];\n}\n\n/** Return the sum and the part of it the sum cannot hold. */\nfunction twoSum(a: number, b: number): [number, number] {\n const sum = a + b;\n const carried = sum - a;\n return [sum, a - (sum - carried) + (b - carried)];\n}\n\n/**\n * Return a sample quantile, by the rule of R's `quantile(type = 7)`.\n *\n * Type 7 is the default of R's `quantile()`, and so the rule behind the\n * `IQR()` that `bw.nrd0()` uses to pick a bandwidth. It reads the sorted\n * values at position `1 + (n - 1) * p` and interpolates between the two\n * neighbors of a fractional position.\n *\n * @param values The observations. The function does not modify them.\n * @param p The probability. It must be in [0, 1].\n * @returns The quantile, or NaN for no values. R returns NA there.\n * @throws RangeError If p is outside [0, 1], as R does.\n */\nexport function quantile(values: readonly number[], p: number): number {\n return quantiles(values, [p])[0] as number;\n}\n\n/**\n * Return several sample quantiles, by the rule of R's `quantile(type = 7)`.\n *\n * R's `quantile()` also takes a vector of probabilities, and for one reason:\n * it sorts once and reads every position off the one sorted copy. Asking for\n * the two quartiles together instead of one at a time halves the work, which\n * is what the bandwidth rule does over a pooled sample.\n *\n * @param values The observations. The function does not modify them.\n * @param probs The probabilities. Each must be in [0, 1].\n * @returns One quantile per probability, in the order given. Each is NaN for\n * no values, where R returns NA.\n * @throws RangeError If a probability is outside [0, 1], as R does.\n */\nexport function quantiles(\n values: readonly number[],\n probs: readonly number[],\n): number[] {\n if (probs.some((p) => !(p >= 0 && p <= 1))) {\n throw new RangeError(`every probability must be in [0, 1], got ${probs}`);\n }\n if (values.length === 0) {\n return probs.map(() => Number.NaN);\n }\n\n // A Float64Array sorts by value with no comparator to call, which is about\n // three times faster than sorting a copy of the array over a pooled sample.\n const sorted = Float64Array.from(values).sort();\n\n return probs.map((p) => type7(sorted, p));\n}\n\n/**\n * Return the median, the value with half the observations on each side.\n *\n * R's `median()` sorts the values and, on an even count, averages the two in\n * the middle. That is the type-7 quantile at 0.5, which weights those same two\n * values by a half each, so this delegates rather than repeat the rule. The\n * two forms land on the same double, the halves included.\n *\n * The sampling demonstration offers this as one of its choices of statistic.\n * It marks the center in the units of the data, as the mean does, but a value\n * far from the center moves it very little, because only the ordering counts.\n *\n * @param values The observations. The function does not modify them.\n * @returns The median, or NaN for no values. R returns NA there.\n */\nexport function median(values: readonly number[]): number {\n return quantile(values, 0.5);\n}\n\n/** Read one type-7 quantile off already sorted values. */\nfunction type7(sorted: Float64Array, p: number): number {\n const position = 1 + (sorted.length - 1) * p;\n const below = Math.floor(position);\n const above = Math.ceil(position);\n // Both indices are inside the array: p in [0, 1] bounds the position by\n // 1 and by the length.\n const low = sorted[below - 1] as number;\n const high = sorted[above - 1] as number;\n\n if (position > below && high !== low) {\n // R's own form. The algebraically equal low + h * (high - low) rounds\n // differently, and this keeps the last bits with R.\n const h = position - below;\n return (1 - h) * low + h * high;\n }\n return low;\n}\n",
|
|
13
|
+
"/**\n * Special functions that the statistics in `core/` build on.\n *\n * JavaScript has no `lgamma` and no incomplete beta, so the distribution\n * functions need them here. R gets the same quantities from its own C\n * routines; this module is the port's replacement.\n *\n * Every function is pure. None of them touch the DOM or hold state.\n */\n\nimport { sum } from \"./arith\";\n\n/**\n * Lanczos parameter and coefficients, g = 607/128 with 15 terms.\n *\n * This set holds about 15 correct digits over the whole positive real line,\n * which is what the t quantiles need at 1e-12 relative tolerance.\n */\nconst LANCZOS_G = 607 / 128;\n\nconst LANCZOS_LEAD = 0.99999999999999709182;\n\nconst LANCZOS_TAIL: readonly number[] = [\n 57.156235665862923517, -59.597960355475491248, 14.136097974741747174,\n -0.49191381609762019978, 0.33994649984811888699e-4,\n 0.46523628927048575665e-4, -0.98374475304879564677e-4,\n 0.15808870322491248884e-3, -0.21026444172410488319e-3,\n 0.2174396181152126432e-3, -0.16431810653676389022e-3,\n 0.84418223983852743293e-4, -0.2619083840158140867e-4,\n 0.36899182659531622704e-5,\n];\n\nconst LOG_SQRT_TWO_PI = 0.5 * Math.log(2 * Math.PI);\n\n/**\n * The Lanczos series A(x), the slowly varying part of the approximation\n *\n * Γ(x) = √(2π) · (x + g − ½)^(x − ½) · e^−(x + g − ½) · A(x)\n */\nfunction lanczosSeries(x: number): number {\n return (\n LANCZOS_LEAD +\n sum(LANCZOS_TAIL.map((coefficient, index) => coefficient / (x + index)))\n );\n}\n\n/**\n * The natural log of the gamma function, R's `lgamma()`.\n *\n * @param x A positive number.\n * @returns log Γ(x), or NaN if x is zero or less.\n */\nexport function logGamma(x: number): number {\n if (!(x > 0)) {\n return Number.NaN;\n }\n const shifted = x + LANCZOS_G - 0.5;\n return (\n LOG_SQRT_TWO_PI +\n (x - 0.5) * Math.log(shifted) -\n shifted +\n Math.log(lanczosSeries(x))\n );\n}\n\n/**\n * The natural log of the beta function, R's `lbeta()`.\n *\n * The obvious route, `logGamma(a) + logGamma(b) - logGamma(a + b)`, subtracts\n * numbers near 600 for the degrees of freedom this package plots, and loses\n * about three digits doing so. Expanding the Lanczos form first cancels the\n * large terms by hand: the exponential parts collapse to the constant\n * −(g − ½), and the logarithmic parts become ratios that stay of order one.\n * What is left has no cancellation at all.\n *\n * Both ratios go through `log1p`. Each one sits just below 1, and taking the\n * quotient first would round away the small part that the log then reads —\n * a loss that grows with the larger argument, reaching 1e-13 by b = 2500.\n *\n * @param a A positive number.\n * @param b A positive number.\n * @returns log B(a, b), or NaN if either argument is zero or less.\n */\nexport function logBeta(a: number, b: number): number {\n if (!(a > 0) || !(b > 0)) {\n return Number.NaN;\n }\n const shiftedSum = a + b + LANCZOS_G - 0.5;\n return (\n LOG_SQRT_TWO_PI -\n (LANCZOS_G - 0.5) +\n Math.log(lanczosSeries(a)) +\n Math.log(lanczosSeries(b)) -\n Math.log(lanczosSeries(a + b)) +\n (a - 0.5) * Math.log1p(-b / shiftedSum) +\n (b - 0.5) * Math.log1p(-a / shiftedSum) -\n 0.5 * Math.log(shiftedSum)\n );\n}\n\n/** Iteration caps and guards for the continued fraction. */\nconst FRACTION_MAX_STEPS = 400;\nconst FRACTION_EPSILON = 3e-16;\nconst FRACTION_FLOOR = 1e-300;\n\n/**\n * The continued fraction of the incomplete beta function, by the modified\n * Lentz method.\n *\n * The loop is index based on purpose: it refines one running value step by\n * step and stops on a convergence test, so there is no array to map over.\n */\nfunction betaContinuedFraction(x: number, a: number, b: number): number {\n const total = a + b;\n const aPlus = a + 1;\n const aMinus = a - 1;\n\n let c = 1;\n let d = 1 - (total * x) / aPlus;\n if (Math.abs(d) < FRACTION_FLOOR) {\n d = FRACTION_FLOOR;\n }\n d = 1 / d;\n let value = d;\n\n for (let step = 1; step <= FRACTION_MAX_STEPS; step += 1) {\n const twice = 2 * step;\n\n const even = (step * (b - step) * x) / ((aMinus + twice) * (a + twice));\n d = 1 + even * d;\n if (Math.abs(d) < FRACTION_FLOOR) {\n d = FRACTION_FLOOR;\n }\n c = 1 + even / c;\n if (Math.abs(c) < FRACTION_FLOOR) {\n c = FRACTION_FLOOR;\n }\n d = 1 / d;\n value *= d * c;\n\n const odd = (-(a + step) * (total + step) * x) / ((a + twice) * (aPlus + twice));\n d = 1 + odd * d;\n if (Math.abs(d) < FRACTION_FLOOR) {\n d = FRACTION_FLOOR;\n }\n c = 1 + odd / c;\n if (Math.abs(c) < FRACTION_FLOOR) {\n c = FRACTION_FLOOR;\n }\n d = 1 / d;\n\n const delta = d * c;\n value *= delta;\n if (Math.abs(delta - 1) < FRACTION_EPSILON) {\n break;\n }\n }\n\n return value;\n}\n\n/**\n * The regularized incomplete beta function I_x(a, b), R's `pbeta()`.\n *\n * The continued fraction converges quickly only on one side of the\n * distribution, so the function evaluates the mirrored form when x sits above\n * the switch point and takes the complement.\n *\n * @param x A value between 0 and 1.\n * @param a A positive shape.\n * @param b A positive shape.\n * @returns The share of the beta density below x, or NaN for a bad shape.\n */\nexport function incompleteBeta(x: number, a: number, b: number): number {\n if (Number.isNaN(x)) {\n return Number.NaN;\n }\n if (x <= 0) {\n return 0;\n }\n if (x >= 1) {\n return 1;\n }\n return incompleteBetaSplit(x, 1 - x, a, b);\n}\n\n/**\n * The regularized incomplete beta function, told x and 1 − x separately.\n *\n * A caller that can write down both members of the pair should use this\n * instead of `incompleteBeta`. Once x is within 1e-16 of 1, the double\n * holding it has no room left for 1 − x, and rebuilding the complement by\n * subtraction throws away the very digits the answer rests on. `pt()` reads\n * both straight off t and df, so it gives up nothing.\n *\n * The two are treated as an exact pair, not as one value and a derived one:\n * each logarithm is taken from whichever member still carries its precision.\n *\n * @param x A value between 0 and 1.\n * @param complement The value of 1 − x, computed without subtracting.\n * @param a A positive shape.\n * @param b A positive shape.\n * @returns The share of the beta density below x, or NaN for a bad shape.\n */\nexport function incompleteBetaSplit(\n x: number,\n complement: number,\n a: number,\n b: number,\n): number {\n if (Number.isNaN(x) || Number.isNaN(complement) || !(a > 0) || !(b > 0)) {\n return Number.NaN;\n }\n if (x <= 0) {\n return 0;\n }\n if (complement <= 0) {\n return 1;\n }\n\n const logX = complement < 0.5 ? Math.log1p(-complement) : Math.log(x);\n const logComplement = x < 0.5 ? Math.log1p(-x) : Math.log(complement);\n const front = Math.exp(a * logX + b * logComplement - logBeta(a, b));\n\n if (x < (a + 1) / (a + b + 2)) {\n return (front * betaContinuedFraction(x, a, b)) / a;\n }\n return 1 - (front * betaContinuedFraction(complement, b, a)) / b;\n}\n\n/** Iteration cap and tolerance for the incomplete gamma routines. */\nconst GAMMA_MAX_STEPS = 1000;\nconst GAMMA_EPSILON = 3e-16;\n\n/**\n * P(a, x), the regularized lower incomplete gamma, by its power series.\n *\n * The series converges quickly while x stays below a + 1. Index loop with a\n * stated reason: it sums one term at a time and stops on a size test.\n */\nfunction lowerGammaSeries(a: number, x: number): number {\n let term = 1 / a;\n let total = term;\n for (let step = 1; step <= GAMMA_MAX_STEPS; step += 1) {\n term *= x / (a + step);\n total += term;\n if (Math.abs(term) < Math.abs(total) * GAMMA_EPSILON) {\n break;\n }\n }\n return total * Math.exp(-x + a * Math.log(x) - logGamma(a));\n}\n\n/**\n * Q(a, x), the regularized upper incomplete gamma, by the modified Lentz\n * method on its continued fraction.\n *\n * This is the branch that carries the far normal tail, where the answer runs\n * to 1e-70 and below and must stay accurate relative to itself.\n */\nfunction upperGammaFraction(a: number, x: number): number {\n let b = x + 1 - a;\n let c = 1 / FRACTION_FLOOR;\n let d = 1 / b;\n let value = d;\n\n for (let step = 1; step <= GAMMA_MAX_STEPS; step += 1) {\n const numerator = -step * (step - a);\n b += 2;\n d = numerator * d + b;\n if (Math.abs(d) < FRACTION_FLOOR) {\n d = FRACTION_FLOOR;\n }\n c = b + numerator / c;\n if (Math.abs(c) < FRACTION_FLOOR) {\n c = FRACTION_FLOOR;\n }\n d = 1 / d;\n const delta = d * c;\n value *= delta;\n if (Math.abs(delta - 1) < GAMMA_EPSILON) {\n break;\n }\n }\n\n return value * Math.exp(-x + a * Math.log(x) - logGamma(a));\n}\n\n/** Q(a, x), taking whichever of the two routes converges at this x. */\nfunction upperGamma(a: number, x: number): number {\n if (x <= 0) {\n return 1;\n }\n if (!Number.isFinite(x)) {\n return 0;\n }\n return x < a + 1 ? 1 - lowerGammaSeries(a, x) : upperGammaFraction(a, x);\n}\n\n/**\n * The standard normal distribution function, R's `pnorm()`.\n *\n * Built on the identity Φ(−z) = ½ · Q(½, z²/2), which keeps the far tail\n * accurate relative to itself rather than losing it against 1. The\n * non-central t needs Φ(−ncp) down to 1e-72 at the widest slider settings.\n *\n * @param z Where to evaluate the distribution.\n * @returns A probability between 0 and 1, or NaN for a NaN input.\n */\nexport function normalCdf(z: number): number {\n if (Number.isNaN(z)) {\n return Number.NaN;\n }\n const lower = 0.5 * upperGamma(0.5, 0.5 * z * z);\n return z > 0 ? 1 - lower : lower;\n}\n\n/** The largest double below 1. The inverse never returns 1 itself. */\nconst BELOW_ONE = 1 - Number.EPSILON / 2;\n\n/** Iteration cap for the inverse. Newton needs about 8 steps; 200 is slack. */\nconst INVERSE_MAX_STEPS = 200;\n\n/**\n * A starting point for the inverse, from Numerical Recipes.\n *\n * Both branches are approximations only. The Newton loop that follows carries\n * the value the rest of the way, so the guess needs to be in the right\n * neighborhood, not accurate.\n */\nfunction inverseGuess(p: number, a: number, b: number): number {\n if (a >= 1 && b >= 1) {\n const tail = p < 0.5 ? p : 1 - p;\n const t = Math.sqrt(-2 * Math.log(tail));\n const normal =\n (p < 0.5 ? -1 : 1) *\n ((2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t);\n const scale = (normal * normal - 3) / 6;\n const harmonic = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));\n const w =\n (normal * Math.sqrt(scale + harmonic)) / harmonic -\n (1 / (2 * b - 1) - 1 / (2 * a - 1)) *\n (scale + 5 / 6 - 2 / (3 * harmonic));\n return a / (a + b * Math.exp(2 * w));\n }\n\n const lower = Math.exp(a * Math.log(a / (a + b))) / a;\n const upper = Math.exp(b * Math.log(b / (a + b))) / b;\n const total = lower + upper;\n if (p < lower / total) {\n return Math.pow(a * total * p, 1 / a);\n }\n return 1 - Math.pow(b * total * (1 - p), 1 / b);\n}\n\n/**\n * The inverse of the regularized incomplete beta function, R's `qbeta()`.\n *\n * Newton's method on I_x(a, b) − p, with the exact beta density as the\n * derivative. Every step keeps a bracket, and a step that leaves the bracket\n * falls back to bisection, so the loop cannot run away on a poor guess.\n *\n * @param p A probability between 0 and 1.\n * @param a A positive shape.\n * @param b A positive shape.\n * @returns The x where I_x(a, b) equals p, or NaN for a bad shape.\n */\nexport function inverseIncompleteBeta(\n p: number,\n a: number,\n b: number,\n): number {\n if (Number.isNaN(p) || !(a > 0) || !(b > 0)) {\n return Number.NaN;\n }\n if (p <= 0) {\n return 0;\n }\n if (p >= 1) {\n return 1;\n }\n\n const logBetaValue = logBeta(a, b);\n let lower = 0;\n let upper = 1;\n let x = inverseGuess(p, a, b);\n if (!(x > 0) || !(x < 1)) {\n x = 0.5;\n }\n\n // Index loop with a stated reason: this refines a single root and stops on\n // a convergence test.\n for (let step = 0; step < INVERSE_MAX_STEPS; step += 1) {\n const residual = incompleteBeta(x, a, b) - p;\n if (residual < 0) {\n lower = x;\n } else {\n upper = x;\n }\n\n const density = Math.exp(\n (a - 1) * Math.log(x) + (b - 1) * Math.log1p(-x) - logBetaValue,\n );\n let next =\n density > 0 && Number.isFinite(density) ? x - residual / density : Number.NaN;\n if (!(next > lower) || !(next < upper)) {\n next = 0.5 * (lower + upper);\n }\n if (next === x) {\n break;\n }\n\n const moved = Math.abs(next - x);\n x = next;\n if (moved <= Number.EPSILON * x) {\n break;\n }\n }\n\n return Math.min(x, BELOW_ONE);\n}\n",
|
|
14
|
+
"/**\n * The t distribution: density, cumulative probability, and quantile.\n *\n * These are the port of R's `dt()`, `pt()`, and `qt()`. `plot_t_test()` in\n * `../compstatslib/R/t_statistic_plot.R` draws both hypothesis curves from\n * them. Verified against R in `tdist.test.ts`.\n *\n * All three take an optional non-centrality, as in R. Left out or given as 0,\n * they run the central path, which `plot_t_test()` draws the null hypothesis\n * from; given a non-zero value they run the non-central path behind the\n * alternative-hypothesis curve, where the non-centrality is the t statistic\n * itself.\n *\n * A note on how close this comes to R. The non-central routines follow R's\n * own `pnt.c` and `dnt.c` step for step, down to the iteration cap and the\n * error bound. That is on purpose. Both stop the series on an *absolute*\n * bound, so where they stop is part of the answer, and a tidier stopping rule\n * would move the last digits away from R rather than toward the truth. It\n * also means this port inherits R's limits: at a large non-centrality the\n * series terms are built by repeated subtraction and go to noise once they\n * fall below about 1e-16, which is what R's own \"full precision may not have\n * been achieved\" warning reports. Densities near 1e-50 there agree with R in\n * absolute terms only.\n */\n\nimport {\n incompleteBetaSplit,\n inverseIncompleteBeta,\n logBeta,\n normalCdf,\n} from \"./special\";\n\n/** True when a non-centrality was given and is not the central case. */\nfunction isNonCentral(ncp: number | undefined): ncp is number {\n return ncp !== undefined && ncp !== 0;\n}\n\n/** True when any argument rules the answer out before any work starts. */\nfunction isBadArgument(value: number, df: number, ncp: number | undefined): boolean {\n return (\n Number.isNaN(value) ||\n !(df > 0) ||\n (ncp !== undefined && Number.isNaN(ncp))\n );\n}\n\n/**\n * The density of the t distribution, R's `dt()`.\n *\n * @param x Where to evaluate the density.\n * @param df Degrees of freedom. Any positive number, whole or not.\n * @param ncp The non-centrality. Left out, or 0, gives the central density.\n * @returns The density, or NaN if df is zero or less.\n */\nexport function dt(x: number, df: number, ncp?: number): number {\n if (isBadArgument(x, df, ncp)) {\n return Number.NaN;\n }\n return isNonCentral(ncp)\n ? nonCentralDensity(x, df, ncp)\n : centralDensity(x, df);\n}\n\n/**\n * The share of the distribution below x, R's `pt()`.\n *\n * @param x Where to evaluate the distribution.\n * @param df Degrees of freedom. Any positive number, whole or not.\n * @param ncp The non-centrality. Left out, or 0, gives the central case.\n * @returns A probability between 0 and 1, or NaN if df is zero or less.\n */\nexport function pt(x: number, df: number, ncp?: number): number {\n if (isBadArgument(x, df, ncp)) {\n return Number.NaN;\n }\n return isNonCentral(ncp)\n ? nonCentralProbability(x, df, ncp)\n : centralProbability(x, df);\n}\n\n/**\n * The value with probability p below it, R's `qt()`.\n *\n * @param p A probability between 0 and 1. The ends give infinities, as in R.\n * @param df Degrees of freedom. Any positive number, whole or not.\n * @param ncp The non-centrality. Left out, or 0, gives the central case.\n * @returns The quantile, or NaN for a p outside 0 to 1 or a df of zero or\n * less.\n */\nexport function qt(p: number, df: number, ncp?: number): number {\n if (isBadArgument(p, df, ncp) || p < 0 || p > 1) {\n return Number.NaN;\n }\n return isNonCentral(ncp)\n ? nonCentralQuantile(p, df, ncp)\n : centralQuantile(p, df);\n}\n\n/**\n * The density, computed in logs.\n *\n * f(x) = (1 + x²/df)^−(df+1)/2 / (√df · B(½, df/2))\n *\n * `log1p` keeps the small-x end accurate, and the log form keeps the large-df\n * end from overflowing on the way to a modest answer.\n */\nfunction centralDensity(x: number, df: number): number {\n if (!Number.isFinite(x)) {\n return 0;\n }\n const logDensity =\n -0.5 * Math.log(df) -\n logBeta(0.5, df / 2) -\n ((df + 1) / 2) * Math.log1p((x * x) / df);\n return Math.exp(logDensity);\n}\n\n/**\n * The cumulative probability, from the upper tail outward.\n *\n * Working from whichever tail holds the smaller mass avoids subtracting two\n * nearly equal numbers, which is what makes the far tails accurate.\n */\nfunction centralProbability(x: number, df: number): number {\n if (x === 0) {\n return 0.5;\n }\n if (x === Number.POSITIVE_INFINITY) {\n return 1;\n }\n if (x === Number.NEGATIVE_INFINITY) {\n return 0;\n }\n const tail = upperTail(Math.abs(x), df);\n return x < 0 ? tail : 1 - tail;\n}\n\n/**\n * The mass above t, for a t of zero or more.\n *\n * P(T > t) = ½ · I_z(df/2, ½), z = df / (df + t²)\n *\n * This is the incomplete-beta identity R's `pt()` uses. Both z and 1 − z come\n * straight out of t and df, each to full precision, so the pair goes to\n * `incompleteBetaSplit` rather than letting it subtract one from the other. A\n * small t drives z against 1, where a subtracted complement would keep only a\n * handful of digits; a large t makes the answer tiny, where building it as\n * ½ − something would cancel it away to nothing.\n */\nfunction upperTail(t: number, df: number): number {\n const squared = t * t;\n if (!Number.isFinite(squared)) {\n // t is past 1e154. The mass above it is far below the smallest double.\n return 0;\n }\n const total = df + squared;\n return 0.5 * incompleteBetaSplit(df / total, squared / total, df / 2, 0.5);\n}\n\n/** How many Newton steps the quantile takes after the beta inverse. */\nconst POLISH_MAX_STEPS = 4;\n\n/**\n * The quantile, by inverting the incomplete beta and then polishing.\n *\n * The symmetry of the distribution turns a one-sided probability into a\n * two-sided mass, which the beta inverse handles. Which shape goes first\n * depends on which side is small: taking the large side would compute the\n * answer as one minus something near one and throw away digits.\n */\nfunction centralQuantile(p: number, df: number): number {\n if (p === 0.5) {\n return 0;\n }\n if (p <= 0) {\n return Number.NEGATIVE_INFINITY;\n }\n if (p >= 1) {\n return Number.POSITIVE_INFINITY;\n }\n\n const tail = p < 0.5 ? p : 1 - p;\n const sign = p < 0.5 ? -1 : 1;\n const twoSided = 2 * tail;\n\n let squared: number;\n if (twoSided > 0.5) {\n // Near the middle: the answer is small, so solve for x²/(df + x²).\n const near = inverseIncompleteBeta(1 - twoSided, 0.5, df / 2);\n squared = (df * near) / (1 - near);\n } else {\n // Out in a tail: the answer is large, so solve for df/(df + x²).\n const far = inverseIncompleteBeta(twoSided, df / 2, 0.5);\n squared = (df * (1 - far)) / far;\n }\n\n return sign * polish(Math.sqrt(squared), tail, df);\n}\n\n/**\n * Newton steps on the upper tail, to take the last digits home.\n *\n * The beta inverse lands close but loses a little precision on the way\n * through x² and the square root. Solving P(T > t) = tail directly, with the\n * density as the derivative, recovers it. The step is measured against the\n * tail rather than against p, so a p near 1 does not lose its digits to the\n * subtraction.\n */\nfunction polish(start: number, tail: number, df: number): number {\n let t = start;\n\n // Index loop with a stated reason: this refines a single root and stops on\n // a convergence test.\n for (let step = 0; step < POLISH_MAX_STEPS; step += 1) {\n const density = centralDensity(t, df);\n if (!(density > 0) || !Number.isFinite(t)) {\n break;\n }\n\n const move = (upperTail(t, df) - tail) / density;\n const next = t + move;\n if (!(next > 0) || !Number.isFinite(next) || Math.abs(move) > 0.25 * t) {\n break;\n }\n if (next === t) {\n break;\n }\n\n t = next;\n if (Math.abs(move) <= Number.EPSILON * t) {\n break;\n }\n }\n\n return t;\n}\n\n/**\n * Iteration cap and error bound for the AS 243 series.\n *\n * These are R's own values from `pnt.c`. They are part of the answer, not a\n * detail: the series stops on an *absolute* bound, so where it stops decides\n * the last digits. Holding R's numbers here is what makes this port agree\n * with R rather than merely come close to the true value.\n */\nconst SERIES_MAX_STEPS = 1000;\nconst SERIES_ERROR_MAX = 1e-12;\n\n/** Above this non-centrality R leaves the series for a normal fit. */\nconst SERIES_NCP_LIMIT_SQUARED = 2 * Math.LN2 * 1022;\n\n/** Above this many degrees of freedom R does the same. */\nconst SERIES_DF_LIMIT = 4e5;\n\nconst SQRT_TWO_OVER_PI = Math.sqrt(2 / Math.PI);\n\n/**\n * The share of the non-central distribution below x, R's `pt(x, df, ncp)`.\n *\n * The series only runs on values of zero or more, so a negative x is\n * reflected through the origin along with the non-centrality. That names the\n * other tail, which the caller flips back.\n */\nfunction nonCentralProbability(x: number, df: number, ncp: number): number {\n if (x === Number.POSITIVE_INFINITY) {\n return 1;\n }\n if (x === Number.NEGATIVE_INFINITY) {\n return 0;\n }\n\n const reflected = x < 0;\n const t = reflected ? -x : x;\n const delta = reflected ? -ncp : ncp;\n const lower =\n df > SERIES_DF_LIMIT || delta * delta > SERIES_NCP_LIMIT_SQUARED\n ? normalApproximation(t, df, delta)\n : lenthSeries(t, df, delta);\n\n return reflected ? 1 - lower : lower;\n}\n\n/**\n * Abramowitz and Stegun 26.7.10, the fit R falls back on.\n *\n * Past a non-centrality of about 37.6 the leading Poisson weight\n * exp(−ncp²/2) drops below the smallest double and the series has nothing\n * left to sum. The sliders reach that: a difference of 4 with a standard\n * deviation of 1 over 500 observations puts the non-centrality near 89.\n */\nfunction normalApproximation(t: number, df: number, delta: number): number {\n const shrink = 1 / (4 * df);\n const spread = Math.sqrt(1 + t * t * 2 * shrink);\n return normalCdf((t * (1 - shrink) - delta) / spread);\n}\n\n/**\n * The AS 243 twin series of Lenth (1989), as R's `pnt.c` runs it.\n *\n * The distribution is a Poisson mixture of incomplete beta terms. Both\n * families of terms step by recurrence rather than being evaluated afresh,\n * and `remaining` carries the Poisson mass still to come, which bounds the\n * error of stopping early.\n *\n * @param t Where to evaluate, zero or more.\n * @param df Degrees of freedom.\n * @param delta The non-centrality, of either sign.\n */\nfunction lenthSeries(t: number, df: number, delta: number): number {\n const squared = t * t;\n const total = df + squared;\n const x = squared / total;\n const complement = df / total;\n\n let sum = 0;\n if (x > 0) {\n const lambda = delta * delta;\n let oddWeight = 0.5 * Math.exp(-0.5 * lambda);\n let evenWeight = SQRT_TWO_OVER_PI * oddWeight * delta;\n\n let remaining = 0.5 - oddWeight;\n if (remaining < 1e-7) {\n remaining = -0.5 * Math.expm1(-0.5 * lambda);\n }\n\n let a = 0.5;\n const b = 0.5 * df;\n const powered = Math.pow(complement, b);\n const logBetaValue = logBeta(0.5, b);\n\n let oddTerm = incompleteBetaSplit(x, complement, a, b);\n let oddStep = 2 * powered * Math.exp(a * Math.log(x) - logBetaValue);\n let evenTerm = 1 - powered;\n let evenStep = b * x * powered;\n sum = oddWeight * oddTerm + evenWeight * evenTerm;\n\n // Index loop with a stated reason: each pass advances one Poisson term by\n // recurrence and the loop stops on an error bound, not on a data length.\n for (let step = 1; step <= SERIES_MAX_STEPS; step += 1) {\n a += 1;\n oddTerm -= oddStep;\n evenTerm -= evenStep;\n oddStep *= (x * (a + b - 1)) / a;\n evenStep *= (x * (a + b - 0.5)) / (a + 0.5);\n oddWeight *= lambda / (2 * step);\n evenWeight *= lambda / (2 * step + 1);\n remaining -= oddWeight;\n if (remaining <= 0) {\n break;\n }\n sum += oddWeight * oddTerm + evenWeight * evenTerm;\n if (Math.abs(2 * remaining * (oddTerm - oddStep)) < SERIES_ERROR_MAX) {\n break;\n }\n }\n }\n\n return Math.min(Math.max(sum + normalCdf(-delta), 0), 1);\n}\n\n/**\n * The density of the non-central distribution, R's `dt(x, df, ncp)`.\n *\n * Away from zero the density is read off the distribution function, using\n * that its derivative can be written as a difference between two evaluations\n * two degrees of freedom apart. R notes in `dnt.c` that this still cancels,\n * and it does: at x = 1 the two probabilities agree to about two digits\n * before the difference is taken. Following R's route rather than a cleaner\n * one is deliberate, since the fixtures are R's own output.\n */\nfunction nonCentralDensity(x: number, df: number, ncp: number): number {\n if (!Number.isFinite(x)) {\n return 0;\n }\n\n if (Math.abs(x) > Math.sqrt(df * Number.EPSILON)) {\n const stepped = x * Math.sqrt((df + 2) / df);\n const difference =\n nonCentralProbability(stepped, df + 2, ncp) -\n nonCentralProbability(x, df, ncp);\n return (df / Math.abs(x)) * Math.abs(difference);\n }\n\n // At zero that difference is 0/0. The density there is the central one\n // damped by the non-centrality, exp(−ncp²/2).\n return Math.exp(\n -0.5 * Math.log(df) - logBeta(0.5, df / 2) - 0.5 * ncp * ncp,\n );\n}\n\n/** Iteration cap for the non-central quantile search. */\nconst QUANTILE_MAX_STEPS = 200;\n\n/**\n * The non-central quantile, R's `qt(p, df, ncp)`.\n *\n * There is no closed form to invert, so this brackets the root and then works\n * inward. R bisects to a relative 1e-13; Newton steps get there in a handful\n * of passes instead, with the bracket kept so that a step into the flat part\n * of a far tail cannot run away.\n */\nfunction nonCentralQuantile(p: number, df: number, ncp: number): number {\n if (p <= 0) {\n return Number.NEGATIVE_INFINITY;\n }\n if (p >= 1) {\n return Number.POSITIVE_INFINITY;\n }\n\n // Widen outward from the non-centrality until the root is enclosed.\n let upper = Math.max(1, ncp);\n while (\n Number.isFinite(upper) &&\n nonCentralProbability(upper, df, ncp) < p\n ) {\n upper *= 2;\n }\n let lower = Math.min(-1, -ncp);\n while (\n Number.isFinite(lower) &&\n nonCentralProbability(lower, df, ncp) > p\n ) {\n lower *= 2;\n }\n\n let t = 0.5 * (lower + upper);\n\n // Index loop with a stated reason: this refines a single root and stops on\n // a convergence test.\n for (let step = 0; step < QUANTILE_MAX_STEPS; step += 1) {\n const residual = nonCentralProbability(t, df, ncp) - p;\n if (residual < 0) {\n lower = t;\n } else {\n upper = t;\n }\n\n const density = nonCentralDensity(t, df, ncp);\n let next =\n density > 0 && Number.isFinite(density) ? t - residual / density : Number.NaN;\n if (!(next > lower) || !(next < upper)) {\n next = 0.5 * (lower + upper);\n }\n if (next === t) {\n break;\n }\n\n const moved = Math.abs(next - t);\n t = next;\n if (moved <= Number.EPSILON * Math.abs(t)) {\n break;\n }\n }\n\n return t;\n}\n",
|
|
15
|
+
"/**\n * A matrix, held the way R holds one.\n *\n * R stores a matrix as one vector in column-major order with a `dim`\n * attribute and optional `dimnames`. This module keeps that shape as a plain\n * object: a `Float64Array` of the entries column by column, the two extents,\n * and the names. Plain data, not a class — a matrix serializes, clones and\n * crosses a worker boundary as it is, and every operation on it is a function\n * in R's vocabulary (`t`, `matmul`, `crossprod`, `cbind`, …) in `ops.ts`.\n *\n * Column-major is load-bearing. It is what R, LAPACK and every conformance\n * fixture assume, so `matrix(c(x1, y1, x2, y2), nrow = 2)` translates with\n * no reordering, and a factorization ported from LINPACK reads the same\n * memory in the same order.\n *\n * Indices are zero-based throughout, as the language's are. R's `A[1, 1]` is\n * `at(a, 0, 0)` here.\n *\n * R recycles the data to fill the matrix: a scalar silently, a sub-multiple\n * of the extent silently too (`matrix(1:3, 3, 2)` repeats the column), and\n * any other length with a warning. This module recycles a scalar only —\n * `matrix([0], {nrow: 3, ncol: 3})` is R's `matrix(0, 3, 3)` — and refuses\n * every other mismatch, warned or not. A silently recycled column lets a\n * typo fit the wrong model; a caller who wants the repeat writes\n * `cbind(v, v)`.\n */\n\nimport {\n frameRows,\n numericColumns,\n requireNumericColumn,\n type DataFrame,\n} from \"../frame\";\nimport type { Vector } from \"./vector\";\n\n/** Row names and column names, either of which R may leave `NULL`. */\nexport type Dimnames = readonly [\n readonly string[] | null,\n readonly string[] | null,\n];\n\n/** A matrix in R's layout: column-major data with its two extents. */\nexport interface Matrix {\n readonly nrow: number;\n readonly ncol: number;\n /**\n * The entries, column by column: entry `(i, j)` is `data[j * nrow + i]`.\n * Treat it as read-only. A `Float64Array` has no read-only type, so the\n * rule is stated rather than enforced.\n */\n readonly data: Float64Array;\n /** R's `dimnames`, or null when the matrix has none. */\n readonly dimnames: Dimnames | null;\n}\n\n/** The named arguments of R's `matrix()`. */\nexport interface MatrixOptions {\n /** The number of rows. At least one of `nrow` and `ncol` is required. */\n readonly nrow?: number;\n /** The number of columns. */\n readonly ncol?: number;\n /** Fill row by row instead of column by column. False by default. */\n readonly byrow?: boolean;\n /** Row names and column names. */\n readonly dimnames?: Dimnames;\n}\n\n/**\n * Build a matrix from its entries, as R's `matrix()` does.\n *\n * @param values The entries, in column-major order unless `byrow` is set,\n * or a single value to fill the whole matrix with. The function copies\n * them; a hole in a sparse array reads as NaN.\n * @param options `nrow` or `ncol` (or both, in which case they must agree\n * with the length), `byrow`, and `dimnames`. An extent may be zero, as\n * R's may.\n * @returns The matrix.\n * @throws RangeError If neither extent is given, an extent is not a\n * non-negative integer, the length is not a multiple of the extent given\n * (R warns and recycles; the port refuses), both extents are given and do\n * not multiply to the length (R recycles a sub-multiple silently; the port\n * refuses), or a dimnames entry has the wrong length.\n */\nexport function matrix(\n values: Vector,\n options: MatrixOptions,\n): Matrix {\n const { byrow = false, dimnames } = options;\n const [nrow, ncol] = extents(values.length, options);\n // A typed array has no holes, so every fill path below sees the same\n // dense sequence, with NaN where the caller's array had a gap.\n const dense = Float64Array.from(values);\n\n const data = new Float64Array(nrow * ncol);\n if (dense.length === 1 && data.length > 1) {\n data.fill(dense[0] as number);\n } else if (byrow) {\n dense.forEach((value, index) => {\n const i = Math.floor(index / ncol);\n const j = index % ncol;\n data[j * nrow + i] = value;\n });\n } else {\n data.set(dense);\n }\n\n return make(nrow, ncol, data, dimnames ?? null);\n}\n\n/**\n * Resolve `nrow` and `ncol` from whichever the caller gave. A single value\n * fills any extents; otherwise the length must match them.\n */\nfunction extents(\n length: number,\n { nrow, ncol }: MatrixOptions,\n): [number, number] {\n if (nrow === undefined && ncol === undefined) {\n throw new RangeError(\"matrix() needs nrow or ncol\");\n }\n if (nrow !== undefined) {\n requireExtent(nrow, \"nrow\");\n }\n if (ncol !== undefined) {\n requireExtent(ncol, \"ncol\");\n }\n const scalar = length === 1;\n\n if (nrow !== undefined && ncol !== undefined) {\n if (!scalar && nrow * ncol !== length) {\n throw new RangeError(\n length > nrow * ncol\n ? \"data is too long\"\n : `data length [${length}] is not nrow * ncol [${nrow} * ${ncol}]`,\n );\n }\n return [nrow, ncol];\n }\n // One extent given. R's `matrix(numeric(0), nrow = 0)` is 0 x 0.\n const given = (nrow ?? ncol) as number;\n const name = nrow !== undefined ? \"rows\" : \"columns\";\n if (given === 0) {\n if (length !== 0) {\n throw new RangeError(\"data is too long\");\n }\n return [0, 0];\n }\n const other = scalar ? 1 : length / given;\n if (!scalar && length % given !== 0) {\n throw new RangeError(\n `data length [${length}] is not a multiple of the number of ${name} [${given}]`,\n );\n }\n return nrow !== undefined ? [nrow, other] : [other, given];\n}\n\n/** Reject an extent that is not a non-negative integer a double can count. */\nfunction requireExtent(value: number, name: string): void {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative integer, got ${value}`);\n }\n}\n\n/**\n * Assemble a matrix from data already in column-major order, checking the\n * dimnames against the extents and copying the name arrays so that no two\n * matrices share one. The data is taken as is, not copied.\n *\n * @internal Not part of the entry point. The other linalg modules build\n * their results through it.\n */\nexport function make(\n nrow: number,\n ncol: number,\n data: Float64Array,\n dimnames: Dimnames | null,\n): Matrix {\n if (data.length !== nrow * ncol) {\n throw new RangeError(\n `data length [${data.length}] is not nrow * ncol [${nrow} * ${ncol}]`,\n );\n }\n if (dimnames !== null) {\n const [rows, columns] = dimnames;\n if (rows !== null && rows.length !== nrow) {\n throw new RangeError(\n `length of dimnames [1] (${rows.length}) not equal to array extent (${nrow})`,\n );\n }\n if (columns !== null && columns.length !== ncol) {\n throw new RangeError(\n `length of dimnames [2] (${columns.length}) not equal to array extent (${ncol})`,\n );\n }\n dimnames =\n rows === null && columns === null\n ? null\n : [rows === null ? null : [...rows], columns === null ? null : [...columns]];\n }\n return { nrow, ncol, data, dimnames };\n}\n\n/**\n * Build a matrix from its rows.\n *\n * @param rows One array per row, each one value per column. Copied.\n * @returns The matrix.\n * @throws RangeError If there are no rows, a row is empty, or the rows have\n * different lengths.\n */\nexport function fromRows(rows: readonly Vector[]): Matrix {\n const nrow = rows.length;\n const first = rows[0];\n if (first === undefined || first.length === 0) {\n throw new RangeError(\"fromRows() needs at least one row with one value\");\n }\n const ncol = first.length;\n const ragged = rows.findIndex((row) => row.length !== ncol);\n if (ragged !== -1) {\n throw new RangeError(\n `every row needs ${ncol} values; row ${ragged} has ${(rows[ragged] as Vector).length}`,\n );\n }\n\n const data = new Float64Array(nrow * ncol);\n rows.forEach((row, i) => {\n // Through a typed array, so a hole reads as NaN rather than being skipped.\n Float64Array.from(row).forEach((value, j) => {\n data[j * nrow + i] = value;\n });\n });\n return make(nrow, ncol, data, null);\n}\n\n/**\n * Build a matrix from its columns. This is R's `cbind()` over vectors and\n * the natural constructor from a column-keyed data frame.\n *\n * @param columns One array per column, each one value per row. Copied.\n * @returns The matrix.\n * @throws RangeError If there are no columns, a column is empty, or the\n * columns have different lengths.\n */\nexport function fromColumns(\n columns: readonly Vector[],\n): Matrix {\n const ncol = columns.length;\n const first = columns[0];\n if (first === undefined || first.length === 0) {\n throw new RangeError(\n \"fromColumns() needs at least one column with one value\",\n );\n }\n const nrow = first.length;\n const ragged = columns.findIndex((column) => column.length !== nrow);\n if (ragged !== -1) {\n throw new RangeError(\n `every column needs ${nrow} values; column ${ragged} has ${(columns[ragged] as Vector).length}`,\n );\n }\n\n const data = new Float64Array(nrow * ncol);\n columns.forEach((column, j) => {\n data.set(column, j * nrow);\n });\n return make(nrow, ncol, data, null);\n}\n\n/**\n * Read one entry. R's `m[i + 1, j + 1]`.\n *\n * @throws RangeError If the index is outside the matrix.\n */\nexport function at(m: Matrix, i: number, j: number): number {\n if (!Number.isInteger(i) || i < 0 || i >= m.nrow) {\n throw new RangeError(`row index ${i} is outside 0..${m.nrow - 1}`);\n }\n if (!Number.isInteger(j) || j < 0 || j >= m.ncol) {\n throw new RangeError(`column index ${j} is outside 0..${m.ncol - 1}`);\n }\n return m.data[j * m.nrow + i] as number;\n}\n\n/** Read one row as a plain array. R's `m[i + 1, ]`. */\nexport function row(m: Matrix, i: number): number[] {\n if (!Number.isInteger(i) || i < 0 || i >= m.nrow) {\n throw new RangeError(`row index ${i} is outside 0..${m.nrow - 1}`);\n }\n return Array.from({ length: m.ncol }, (_, j) => m.data[j * m.nrow + i] as number);\n}\n\n/** Read one column as a plain array. R's `m[, j + 1]`. */\nexport function column(m: Matrix, j: number): number[] {\n if (!Number.isInteger(j) || j < 0 || j >= m.ncol) {\n throw new RangeError(`column index ${j} is outside 0..${m.ncol - 1}`);\n }\n return Array.from(m.data.subarray(j * m.nrow, (j + 1) * m.nrow));\n}\n\n/** The matrix as an array of rows. */\nexport function toRows(m: Matrix): number[][] {\n return Array.from({ length: m.nrow }, (_, i) => row(m, i));\n}\n\n/** The matrix as an array of columns. */\nexport function toColumns(m: Matrix): number[][] {\n return Array.from({ length: m.ncol }, (_, j) => column(m, j));\n}\n\n/**\n * R's `as.matrix()` of a data frame: the numeric columns side by side, with\n * the column names carried. The natural way into `cov`, `prcomp` and\n * `matmul` from a column-keyed frame.\n *\n * @param data The frame.\n * @param columns The columns to take, in order. By default every numeric\n * column, in frame order — R's `Filter(is.numeric, data)`.\n * @returns The matrix, `frameRows(data)` by `columns.length`, with the\n * column names as its column names.\n * @throws RangeError If a named column is absent or not numeric (through\n * `requireNumericColumn`), or if the frame is ragged.\n */\nexport function fromFrame(data: DataFrame, columns?: readonly string[]): Matrix {\n const nrow = frameRows(data);\n const names = columns ?? numericColumns(data);\n const buffer = new Float64Array(nrow * names.length);\n names.forEach((name, j) => {\n buffer.set(requireNumericColumn(data, name, \"columns\"), j * nrow);\n });\n return make(nrow, names.length, buffer, names.length === 0 ? null : [null, [...names]]);\n}\n",
|
|
16
|
+
"/**\n * R's `model.matrix()`: a data frame and a list of terms → the design\n * matrix, with the column names `lm()` gives its coefficients.\n *\n * R builds this from a formula. The port has no formulas (CLAUDE.md: the\n * canonical form is explicit column names in an options object), so a\n * model is a list of terms — a column name for a main effect, an array of\n * column names for an interaction — and the intercept is a flag. R's\n * `y ~ x * z + w` is `{ outcome: \"y\", terms: [\"x\", \"z\", \"w\", [\"x\", \"z\"]] }`.\n *\n * The columns come out in R's order, whatever order the terms were written\n * in: the intercept, then the terms by degree — every main effect before\n * every two-way interaction before every three-way — and within a degree in\n * the order given. A term written twice enters once. The `assign` vector is\n * R's: the index of the term each column came from, 0 for the intercept.\n *\n * Rows with a missing (non-finite) value in the outcome or in any column a\n * term names are dropped, R's `model.frame()` under `na.omit`; the indices\n * of the rows kept are returned, so a fit can pad its results back to the\n * input order (the `na.exclude` convention every fit in this package uses).\n * Only numeric columns can enter; R's factors and contrasts are out of\n * scope.\n */\n\nimport { frameRows, requireNumericColumn, type DataFrame } from \"../frame\";\nimport { make, type Matrix } from \"./matrix\";\n\n/**\n * One term of a model: a column name for a main effect, or the column names\n * of an interaction, R's `a:b`.\n */\nexport type Term = string | readonly string[];\n\n/** Which columns make the model. */\nexport interface ModelSpec {\n /**\n * The outcome column. It enters no design column, but a row missing it is\n * dropped, as `model.frame()` drops it. Optional here; `lm()` requires it.\n */\n readonly outcome?: string;\n /** The terms, in any order. R's order is restored. */\n readonly terms: readonly Term[];\n /** Whether to lead with a column of ones. True by default, R's `+ 1`. */\n readonly intercept?: boolean;\n}\n\n/** A design matrix and where its rows came from. */\nexport interface ModelMatrix {\n /**\n * The design, one row per complete data row, with the coefficient names\n * as column names: `(Intercept)`, the main effects, the interactions as\n * `a:b`.\n */\n readonly matrix: Matrix;\n /** The data rows the design holds, in input order. */\n readonly rows: readonly number[];\n /** R's `assign`: the term each column came from, 0 for the intercept. */\n readonly assign: readonly number[];\n /** R's `term.labels`: the terms in the order the columns follow. */\n readonly termLabels: readonly string[];\n}\n\n/**\n * Build the design matrix of a model, as R's `model.matrix()` does.\n *\n * @param data The frame holding every column the model names.\n * @param spec The outcome, the terms, and the intercept flag.\n * @returns The design, the rows it kept, and R's `assign` and term labels.\n * @throws RangeError If a named column is absent or not numeric (through\n * `requireNumericColumn`, naming the option it arrived through), if the\n * frame is ragged, or if an interaction term names no column.\n */\nexport function modelMatrix(data: DataFrame, spec: ModelSpec): ModelMatrix {\n const { outcome, intercept = true } = spec;\n const rowCount = frameRows(data);\n const terms = orderTerms(spec.terms);\n\n const columns = new Map<string, readonly number[]>();\n const read = (name: string, role: string): readonly number[] => {\n const held = columns.get(name);\n if (held !== undefined) {\n return held;\n }\n const column = requireNumericColumn(data, name, role);\n columns.set(name, column);\n return column;\n };\n if (outcome !== undefined) {\n read(outcome, \"outcome\");\n }\n terms.forEach((factors) => {\n factors.forEach((name) => read(name, \"terms\"));\n });\n\n // R's na.omit: a row with a missing value in any model column leaves.\n // NaN is this library's missing value, and an infinity would poison the\n // fit the same way, so \"complete\" means finite everywhere.\n const involved = [...columns.values()];\n const rows = Array.from({ length: rowCount }, (_, row) => row).filter((row) =>\n involved.every((column) => Number.isFinite(column[row])),\n );\n\n const termColumns = terms.map((factors) =>\n rows.map((row) =>\n factors.reduce((product, name) => product * ((columns.get(name) as readonly number[])[row] as number), 1),\n ),\n );\n const design = intercept ? [rows.map(() => 1), ...termColumns] : termColumns;\n const names = [\n ...(intercept ? [\"(Intercept)\"] : []),\n ...terms.map((factors) => factors.join(\":\")),\n ];\n const assign = [\n ...(intercept ? [0] : []),\n ...terms.map((_, index) => index + 1),\n ];\n\n const n = rows.length;\n const p = design.length;\n const buffer = new Float64Array(n * p);\n design.forEach((column, j) => {\n buffer.set(column, j * n);\n });\n\n return {\n matrix: make(n, p, buffer, p === 0 ? null : [null, names]),\n rows,\n assign,\n termLabels: names.slice(intercept ? 1 : 0),\n };\n}\n\n/**\n * Normalize the terms to arrays of column names, drop repeats, and put them\n * in R's order: by degree, then as written.\n *\n * @throws RangeError If a term names no column.\n */\nfunction orderTerms(terms: readonly Term[]): readonly (readonly string[])[] {\n const seen = new Set<string>();\n const unique: (readonly string[])[] = [];\n terms.forEach((term) => {\n const factors = typeof term === \"string\" ? [term] : term;\n if (factors.length === 0) {\n throw new RangeError(\"an interaction term needs at least one column name\");\n }\n // R treats `a:b` and `b:a` as one term; the first spelling wins.\n const key = [...factors].sort().join(\"\u0000\");\n if (!seen.has(key)) {\n seen.add(key);\n unique.push(factors);\n }\n });\n // A stable sort by degree keeps the written order within a degree, as R's\n // terms() does.\n return unique\n .map((factors, index) => ({ factors, index }))\n .sort((a, b) => a.factors.length - b.factors.length || a.index - b.index)\n .map(({ factors }) => factors);\n}\n",
|
|
17
|
+
"/**\n * R's named vector: values with a name each, in order.\n *\n * A coefficient vector is the case that matters here — `coef(fit)` in R\n * prints `(Intercept)`, `x`, `z`, `x:z` above its values, and `summary()`\n * lines the standard errors up under the same names. The port holds the\n * names alongside the values rather than in an object keyed by name,\n * because a JavaScript object moves an integer-like key to the front: a\n * column called `\"1\"` would jump ahead of `(Intercept)`. The pair of arrays\n * keeps R's order, and pairs with `dimnames` on a `Matrix`, so the column\n * names of a model matrix become the names of a fit with no reshaping\n * (plan Q11).\n *\n * `null` is R's `NA`: a coefficient the fit could not identify.\n */\n\n/** Values with a name each, in order. */\nexport interface NamedVector {\n readonly names: readonly string[];\n /** One value per name; null where R reports `NA`. */\n readonly values: readonly (number | null)[];\n}\n\n/**\n * Pair names with values.\n *\n * @param names One name per value. Copied.\n * @param values One value per name; null for R's `NA`. Copied.\n * @throws RangeError If the two lengths differ.\n */\nexport function namedVector(\n names: readonly string[],\n values: readonly (number | null)[],\n): NamedVector {\n if (names.length !== values.length) {\n throw new RangeError(\n `a named vector needs one name per value: ${names.length} names, ${values.length} values`,\n );\n }\n return { names: [...names], values: [...values] };\n}\n\n/**\n * Read one value by name. R's `v[[\"name\"]]`.\n *\n * @returns The value, null where the entry is R's `NA`, or undefined when\n * no entry carries the name. With a repeated name, the first.\n */\nexport function lookup(v: NamedVector, name: string): number | null | undefined {\n const index = v.names.indexOf(name);\n return index === -1 ? undefined : (v.values[index] as number | null);\n}\n",
|
|
18
|
+
"/**\n * The elementary matrix operations, named as R names them.\n *\n * `t()`, `%*%` (`matmul`), `crossprod()`, `tcrossprod()`, `cbind()`,\n * `rbind()` and `diag()`. Each takes matrices (and, where R allows it, plain\n * vectors) and returns a new matrix; nothing here modifies its input.\n *\n * A bare vector in a product takes the shape R gives it, which is not\n * always the one that would conform (fixtures 1g and 1h probe the rules).\n * In `%*%`, a left vector is a row when its length matches the rows of the\n * right factor and otherwise a column; a right vector is a column when its\n * length matches the columns of the left factor and otherwise a row; two\n * vectors give their inner product. In `crossprod` a vector `x` is always\n * a column, and a vector `y` is a column when its length matches the rows\n * of `x` and otherwise a row. In `tcrossprod` a vector `x` is a row when\n * its length matches the columns of a matrix `y` and otherwise a column,\n * and a vector `y` is a row only when `x` has one row; two vectors are both\n * columns, the outer product.\n *\n * Dimnames travel as they do in R: a transpose swaps them, a product keeps\n * the row names of the left factor and the column names of the right, and\n * binding stacks them, with `\"\"` for a bare vector joined to a named matrix.\n *\n * The product follows the reference BLAS `dgemm` that R ships: the loop\n * over `i` innermost walks each column of the left factor in order, and each\n * product is rounded once into its running sum with `fusedMultiplyAdd`,\n * because the build the conformance fixtures come from contracts\n * `C + A * B` into one instruction (the fixture README records this; the LU\n * and QR here already follow it). Index loops throughout: a product\n * addresses entries by position. (CLAUDE.md allows an index loop with a\n * stated reason; that is the reason.)\n */\n\nimport { fusedMultiplyAdd } from \"../arith\";\nimport { make, type Dimnames, type Matrix } from \"./matrix\";\nimport type { Vector } from \"./vector\";\n\n/** A matrix, or a vector R would treat as a one-column matrix. */\nexport type MatrixOrVector = Matrix | Vector;\n\n/** R's `t()`. Also exported as `transpose`, for an app whose `t` is already taken. */\nexport function t(m: Matrix): Matrix {\n const { nrow, ncol } = m;\n const data = new Float64Array(nrow * ncol);\n for (let j = 0; j < ncol; j++) {\n for (let i = 0; i < nrow; i++) {\n data[i * ncol + j] = m.data[j * nrow + i] as number;\n }\n }\n const dimnames: Dimnames | null =\n m.dimnames === null ? null : [m.dimnames[1], m.dimnames[0]];\n return make(ncol, nrow, data, dimnames);\n}\n\n/** R's `t()`, under a name that does not collide with an i18n `t`. */\nexport const transpose = t;\n\n/**\n * R's `x %*% y`.\n *\n * @param x The left factor. A vector is a row when its length matches the\n * rows of `y`, else a column when `y` has one row.\n * @param y The right factor. A vector is a column when its length matches\n * the columns of `x`, else a row when `x` has one column. Two vectors of\n * one length give their inner product as a 1 x 1 matrix.\n * @returns The product, with the row names of `x` and the column names of\n * `y`.\n * @throws RangeError If the inner extents differ: R's \"non-conformable\n * arguments\".\n */\nexport function matmul(x: MatrixOrVector, y: MatrixOrVector): Matrix {\n const [left, right] = conformProduct(x, y);\n if (left.ncol !== right.nrow) {\n throw new RangeError(\n `non-conformable arguments: ${left.nrow} x ${left.ncol} %*% ${right.nrow} x ${right.ncol}`,\n );\n }\n const data = product(left, right);\n return make(left.nrow, right.ncol, data, productDimnames(left, right));\n}\n\n/** Shape the factors of `%*%` by R's rules for a bare vector. */\nfunction conformProduct(x: MatrixOrVector, y: MatrixOrVector): [Matrix, Matrix] {\n if (isMatrix(x)) {\n if (isMatrix(y)) {\n return [x, y];\n }\n return [x, y.length === x.ncol ? asColumn(y) : asRow(y)];\n }\n if (isMatrix(y)) {\n return [x.length === y.nrow ? asRow(x) : asColumn(x), y];\n }\n // Two vectors: `x` is a row, and `y` is a row too when `x` is a single\n // value, else a column — the inner product when the lengths agree.\n return [asRow(x), x.length === 1 ? asRow(y) : asColumn(y)];\n}\n\n/**\n * R's `crossprod(x, y)`: `t(x) %*% y`, with `crossprod(x)` for `t(x) %*% x`.\n * A bare vector `x` is a column; a bare vector `y` is a column when its\n * length matches the rows of `x`, else a row (fixture 1h).\n *\n * @throws RangeError If the row counts differ.\n */\nexport function crossprod(x: MatrixOrVector, y: MatrixOrVector = x): Matrix {\n const left = asColumn(x);\n const right = isMatrix(y) ? y : y.length === left.nrow ? asColumn(y) : asRow(y);\n if (left.nrow !== right.nrow) {\n throw new RangeError(\n `non-conformable arguments: crossprod of ${left.nrow} x ${left.ncol} and ${right.nrow} x ${right.ncol}`,\n );\n }\n return matmul(t(left), right);\n}\n\n/**\n * R's `tcrossprod(x, y)`: `x %*% t(y)`, with `tcrossprod(x)` for\n * `x %*% t(x)`. A bare vector `x` is a row when its length matches the\n * columns of a matrix `y`, else a column; a bare vector `y` is a row only\n * when `x` has one row, and two bare vectors are both columns (fixture 1h).\n *\n * @throws RangeError If the column counts differ.\n */\nexport function tcrossprod(x: MatrixOrVector, y: MatrixOrVector = x): Matrix {\n const bothVectors = !isMatrix(x) && !isMatrix(y);\n const left = isMatrix(x) ? x : isMatrix(y) && y.ncol === x.length ? asRow(x) : asColumn(x);\n const right = isMatrix(y)\n ? y\n : !bothVectors && left.nrow === 1\n ? asRow(y)\n : asColumn(y);\n if (left.ncol !== right.ncol) {\n throw new RangeError(\n `non-conformable arguments: tcrossprod of ${left.nrow} x ${left.ncol} and ${right.nrow} x ${right.ncol}`,\n );\n }\n return matmul(left, t(right));\n}\n\n/** The raw product of two conformable matrices, column-major. */\nfunction product(x: Matrix, y: Matrix): Float64Array {\n const { nrow, ncol: inner } = x;\n const { ncol } = y;\n const data = new Float64Array(nrow * ncol);\n for (let j = 0; j < ncol; j++) {\n for (let k = 0; k < inner; k++) {\n const factor = y.data[j * y.nrow + k] as number;\n for (let i = 0; i < nrow; i++) {\n data[j * nrow + i] = fusedMultiplyAdd(\n x.data[k * nrow + i] as number,\n factor,\n data[j * nrow + i] as number,\n );\n }\n }\n }\n return data;\n}\n\n/** Row names of the left factor, column names of the right. */\nfunction productDimnames(x: Matrix, y: Matrix): Dimnames | null {\n const rows = x.dimnames?.[0] ?? null;\n const columns = y.dimnames?.[1] ?? null;\n return rows === null && columns === null ? null : [rows, columns];\n}\n\n/** A vector as R's one-column matrix; a matrix as it is. */\nfunction asColumn(value: MatrixOrVector): Matrix {\n if (isMatrix(value)) {\n return value;\n }\n return make(value.length, 1, Float64Array.from(value), null);\n}\n\n/** A vector as a one-row matrix. */\nfunction asRow(value: Vector): Matrix {\n return make(1, value.length, Float64Array.from(value), null);\n}\n\n/**\n * Tell a matrix from a vector by shape, and refuse anything else — a typed\n * array or a stray object — with a TypeError rather than a wrong shape.\n *\n * @internal Shared with the other linalg modules; not part of the entry.\n */\nexport function isMatrix(value: MatrixOrVector): value is Matrix {\n if (Array.isArray(value)) {\n return false;\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"nrow\" in value &&\n \"ncol\" in value &&\n \"data\" in value\n ) {\n return true;\n }\n throw new TypeError(\"expected a Matrix or an array of numbers\");\n}\n\n/**\n * R's `cbind()`: join matrices and vectors side by side.\n *\n * @param parts Matrices, and vectors taken as columns. At least one.\n * @returns The joined matrix. Row names come from the first part that has\n * them. Column names are kept when any part has them, with `\"\"` for a part\n * that does not, as R names a bare vector.\n * @throws RangeError If the row counts differ, in R's words for a matrix\n * part and for a vector part. R recycles a short vector with a warning;\n * the port refuses.\n */\nexport function cbind(...parts: readonly MatrixOrVector[]): Matrix {\n const matrices = parts.map(asColumn);\n const first = matrices[0];\n if (first === undefined) {\n throw new RangeError(\"cbind() needs at least one argument\");\n }\n const nrow = first.nrow;\n matrices.forEach((m, index) => {\n if (m.nrow !== nrow) {\n throw new RangeError(\n isMatrix(parts[index] as MatrixOrVector)\n ? `number of rows of matrices must match (see arg ${index + 1})`\n : `number of rows of result is not a multiple of vector length (arg ${index + 1})`,\n );\n }\n });\n\n const ncol = matrices.reduce((total, m) => total + m.ncol, 0);\n const data = new Float64Array(nrow * ncol);\n let offset = 0;\n matrices.forEach((m) => {\n data.set(m.data, offset);\n offset += m.data.length;\n });\n\n const rows = matrices.find((m) => m.dimnames?.[0])?.dimnames?.[0] ?? null;\n const columns = boundNames(\n matrices.map((m) => ({ names: m.dimnames?.[1] ?? null, count: m.ncol })),\n );\n return make(nrow, ncol, data, rows === null && columns === null ? null : [rows, columns]);\n}\n\n/**\n * R's `rbind()`: stack matrices and vectors.\n *\n * @param parts Matrices, and vectors taken as rows. At least one.\n * @returns The stacked matrix, with names as `cbind` carries them, rows and\n * columns exchanged.\n * @throws RangeError If the column counts differ.\n */\nexport function rbind(...parts: readonly MatrixOrVector[]): Matrix {\n if (parts.length === 0) {\n throw new RangeError(\"rbind() needs at least one argument\");\n }\n const transposed = parts.map((part) => (isMatrix(part) ? t(part) : part));\n try {\n return t(cbind(...transposed));\n } catch (error) {\n if (error instanceof RangeError) {\n throw new RangeError(\n error.message.replace(\"number of rows\", \"number of columns\"),\n );\n }\n throw error;\n }\n}\n\n/** Concatenate the names of bound parts, `\"\"` where a part has none. */\nfunction boundNames(\n parts: readonly { names: readonly string[] | null; count: number }[],\n): readonly string[] | null {\n if (parts.every((part) => part.names === null)) {\n return null;\n }\n return parts.flatMap(\n (part) => part.names ?? new Array<string>(part.count).fill(\"\"),\n );\n}\n\n/**\n * R's `diag()` in its three forms: a vector gives the diagonal matrix of it,\n * a count gives the identity of that order, and a matrix gives its diagonal.\n *\n * The form is chosen by type, not by length, which is R's own gotcha\n * removed: `diag([5])` is the 1 x 1 matrix `[5]` where R's `diag(c(5))` is\n * the 5 x 5 identity, and `diag(2.5)` refuses where R truncates to 2 x 2.\n * The diagonal of a matrix comes back as a plain array; R names it when the\n * row and column names agree, which the port will do once a named vector\n * exists (plan Q11).\n */\nexport function diag(values: Vector): Matrix;\nexport function diag(order: number): Matrix;\nexport function diag(m: Matrix): number[];\nexport function diag(arg: Vector | number | Matrix): Matrix | number[] {\n if (typeof arg === \"number\") {\n return identity(arg);\n }\n if (Array.isArray(arg)) {\n const values = arg as Vector;\n const n = values.length;\n const data = new Float64Array(n * n);\n values.forEach((value, i) => {\n data[i * n + i] = value;\n });\n return make(n, n, data, null);\n }\n const m = arg as Matrix;\n const n = Math.min(m.nrow, m.ncol);\n return Array.from({ length: n }, (_, i) => m.data[i * m.nrow + i] as number);\n}\n\n/**\n * The identity matrix of the given order. R's `diag(n)`.\n *\n * @throws RangeError If the order is not a non-negative integer.\n */\nexport function identity(order: number): Matrix {\n if (!Number.isInteger(order) || order < 0) {\n throw new RangeError(`order must be a non-negative integer, got ${order}`);\n }\n const data = new Float64Array(order * order);\n for (let i = 0; i < order; i++) {\n data[i * order + i] = 1;\n }\n return make(order, order, data, null);\n}\n",
|
|
19
|
+
"/**\n * The QR factorization, R's `qr()` with `LAPACK = FALSE`.\n *\n * R factors a design with LINPACK's `dqrdc2`, a Householder QR with a\n * limited column-pivoting rule: a column whose norm has collapsed against\n * the columns to its left is moved to the right edge and its coefficient is\n * reported as `NA`. That rule is what makes `lm()` and `glm()` report an\n * aliased coefficient instead of dividing by a near-zero pivot. This module\n * reproduces it and exposes R's result — the compact `qr` matrix, `qraux`,\n * `pivot` and `rank` — and R's readers of it: `qr.coef`, `qr.fitted`,\n * `qr.resid`, `qr.qy`, `qr.qty`, `qr.Q` and `qr.R`. Verified against R in\n * `qr.test.ts`; `leastSquares` in `../ols.ts` is a wrapper over it.\n *\n * Designs here are small — two columns for logit, four for a moderation\n * surface — so the code follows the LINPACK routines plainly rather than\n * blocking or vectorizing them. Index loops throughout: a factorization\n * addresses single entries by position, and this one follows `dqrdc2` and\n * `dqrsl` step for step so that the fixtures pin bit for bit.\n */\n\nimport { fusedMultiplyAdd } from \"../arith\";\nimport { make, type Dimnames, type Matrix } from \"./matrix\";\nimport { isMatrix, type MatrixOrVector } from \"./ops\";\nimport type { Vector } from \"./vector\";\n\n/** R's `qr()` result. */\nexport interface QrDecomposition {\n /**\n * The compact factorization, R's `qr$qr`: `R` on and above the diagonal,\n * the Householder vectors below it, columns in pivot order. Column names\n * follow the pivot, as R's do.\n */\n readonly qr: Matrix;\n /**\n * R's `qr$qraux`: for each reflected column, the leading entry of its\n * Householder reflector; for a column never reflected — the trailing\n * column of a square or wide design, or an aliased column — its remaining\n * norm, which is what R reports there (fixtures 2b, 2c, 2g).\n */\n readonly qraux: Vector;\n /**\n * The column order after pivoting, R's `qr$pivot` **zero-based**:\n * `pivot[k]` is the original index of the column now at position `k`.\n * The aliased columns are at the end.\n */\n readonly pivot: readonly number[];\n /** The number of columns the factorization could identify. */\n readonly rank: number;\n}\n\nexport interface QrOptions {\n /**\n * How far a column's norm may collapse before it is aliased: the column is\n * moved to the end when its remaining norm falls below this fraction of\n * its original norm. The default is R's `qr()` and `lm.fit()` default.\n * `glm.fit()` passes `min(1e-7, epsilon / 1000)`. Zero aliases nothing,\n * as R's `tol = 0` does; a negative or NaN value is refused, where R\n * would pass it through — a deliberate narrowing.\n */\n readonly tolerance?: number;\n}\n\n/** The rank tolerance of R's `qr()` and `lm.fit()`. */\nexport const DEFAULT_QR_TOLERANCE = 1e-7;\n\n/**\n * Factor a matrix, as R's `qr(x, LAPACK = FALSE)` does.\n *\n * @param x The matrix. The function does not modify it. Row names travel\n * onto the compact form; column names follow the pivot.\n * @param options The rank tolerance.\n * @returns The compact factorization, `qraux`, the pivot, and the rank.\n * @throws RangeError If the tolerance is negative or NaN, or if an entry is\n * not finite — R's \"NA/NaN/Inf in foreign function call (arg 1)\". NaN is\n * this library's missing value; a caller drops incomplete rows first, as\n * `modelMatrix` does.\n * @throws TypeError If `x` is not a matrix.\n */\nexport function qr(x: Matrix, options: QrOptions = {}): QrDecomposition {\n const { tolerance = DEFAULT_QR_TOLERANCE } = options;\n if (!(tolerance >= 0)) {\n throw new RangeError(`tolerance must be a non-negative number, got ${tolerance}`);\n }\n if (!isMatrix(x)) {\n throw new TypeError(\"expected a Matrix\");\n }\n if (!x.data.every(Number.isFinite)) {\n throw new RangeError(\"NA/NaN/Inf in foreign function call (arg 1)\");\n }\n const { nrow, ncol } = x;\n\n // Work on a copy of each column. `dqrdc2` overwrites the matrix in place;\n // the copies keep the caller's matrix untouched.\n const columns = Array.from({ length: ncol }, (_, j) =>\n Array.from(x.data.subarray(j * nrow, (j + 1) * nrow)),\n );\n const { householders, pivot, rank } = decompose(columns, tolerance, nrow);\n\n const data = new Float64Array(nrow * ncol);\n columns.forEach((column, j) => {\n data.set(column, j * nrow);\n });\n const rows = x.dimnames?.[0] ?? null;\n const names = x.dimnames?.[1] ?? null;\n const dimnames: Dimnames | null =\n rows === null && names === null\n ? null\n : [rows, names === null ? null : pivot.map((from) => names[from] as string)];\n\n return { qr: make(nrow, ncol, data, dimnames), qraux: householders, pivot, rank };\n}\n\n/**\n * Solve for the coefficients, R's `qr.coef(qr, y)`.\n *\n * @param q The factorization.\n * @param y The response, one value per row — or a matrix with one response\n * per column, as R also takes.\n * @returns One coefficient per column of the factored matrix, **in the\n * original column order**, with null for an aliased column (R's `NA`).\n * For a matrix `y`, a matrix with one column per response, the factored\n * matrix's column names as row names and `y`'s column names as column\n * names; an aliased column reads NaN there, since a matrix holds no null.\n * @throws RangeError If `y` has the wrong number of rows.\n */\nexport function qrCoef(q: QrDecomposition, y: Vector): (number | null)[];\nexport function qrCoef(q: QrDecomposition, y: Matrix): Matrix;\nexport function qrCoef(q: QrDecomposition, y: MatrixOrVector): (number | null)[] | Matrix {\n if (isMatrix(y)) {\n requireRows(q, y.nrow);\n const width = q.qr.ncol;\n const data = new Float64Array(width * y.ncol);\n for (let j = 0; j < y.ncol; j++) {\n const solved = coefficientsOf(q, Array.from(y.data.subarray(j * y.nrow, (j + 1) * y.nrow)));\n solved.forEach((value, i) => {\n data[j * width + i] = value ?? Number.NaN;\n });\n }\n return make(width, y.ncol, data, readerDimnames(originalColumnNames(q), y));\n }\n requireRows(q, y.length);\n return coefficientsOf(q, y);\n}\n\n/** The coefficients of one response, in the original column order. */\nfunction coefficientsOf(q: QrDecomposition, y: Vector): (number | null)[] {\n const qty = transformed(q, y, true);\n const solved = backSubstitute(q.qr, qty, q.rank);\n const coefficients = new Array<number | null>(q.qr.ncol).fill(null);\n q.pivot.slice(0, q.rank).forEach((column, position) => {\n coefficients[column] = solved[position] as number;\n });\n return coefficients;\n}\n\n/** The factored matrix's column names in their original order, if any. */\nfunction originalColumnNames(q: QrDecomposition): readonly string[] | null {\n const pivoted = q.qr.dimnames?.[1] ?? null;\n if (pivoted === null) {\n return null;\n }\n const names = new Array<string>(pivoted.length);\n q.pivot.forEach((original, position) => {\n names[original] = pivoted[position] as string;\n });\n return names;\n}\n\n/**\n * The fitted values, R's `qr.fitted(qr, y)`: `Q` applied to the first `rank`\n * entries of `Qᵀy`, the rest set to zero. A matrix `y` gives a matrix with\n * its column names.\n *\n * @throws RangeError If `y` has the wrong number of rows.\n */\nexport function qrFitted(q: QrDecomposition, y: Vector): number[];\nexport function qrFitted(q: QrDecomposition, y: Matrix): Matrix;\nexport function qrFitted(q: QrDecomposition, y: MatrixOrVector): number[] | Matrix {\n return perColumn(q, y, (column) =>\n transformed(q, transformed(q, column, true).map((value, index) => (index < q.rank ? value : 0)), false),\n );\n}\n\n/**\n * The residuals, R's `qr.resid(qr, y)`: `Q` applied to `Qᵀy` with its first\n * `rank` entries set to zero. A matrix `y` gives a matrix with its column\n * names.\n *\n * @throws RangeError If `y` has the wrong number of rows.\n */\nexport function qrResid(q: QrDecomposition, y: Vector): number[];\nexport function qrResid(q: QrDecomposition, y: Matrix): Matrix;\nexport function qrResid(q: QrDecomposition, y: MatrixOrVector): number[] | Matrix {\n return perColumn(q, y, (column) =>\n transformed(q, transformed(q, column, true).map((value, index) => (index < q.rank ? 0 : value)), false),\n );\n}\n\n/**\n * `Qᵀy`, R's `qr.qty(qr, y)`: the reflectors applied first to last. A\n * matrix `y` gives a matrix with its column names.\n *\n * @throws RangeError If `y` has the wrong number of rows.\n */\nexport function qrQty(q: QrDecomposition, y: Vector): number[];\nexport function qrQty(q: QrDecomposition, y: Matrix): Matrix;\nexport function qrQty(q: QrDecomposition, y: MatrixOrVector): number[] | Matrix {\n return perColumn(q, y, (column) => transformed(q, column, true));\n}\n\n/**\n * `Qy`, R's `qr.qy(qr, y)`: the reflectors applied last to first. A matrix\n * `y` gives a matrix with its column names.\n *\n * @throws RangeError If `y` has the wrong number of rows.\n */\nexport function qrQy(q: QrDecomposition, y: Vector): number[];\nexport function qrQy(q: QrDecomposition, y: Matrix): Matrix;\nexport function qrQy(q: QrDecomposition, y: MatrixOrVector): number[] | Matrix {\n return perColumn(q, y, (column) => transformed(q, column, false));\n}\n\n/** Apply a vector reader to a vector, or to each column of a matrix. */\nfunction perColumn(\n q: QrDecomposition,\n y: MatrixOrVector,\n read: (column: Vector) => number[],\n): number[] | Matrix {\n if (isMatrix(y)) {\n requireRows(q, y.nrow);\n const data = new Float64Array(y.nrow * y.ncol);\n for (let j = 0; j < y.ncol; j++) {\n data.set(read(Array.from(y.data.subarray(j * y.nrow, (j + 1) * y.nrow))), j * y.nrow);\n }\n return make(y.nrow, y.ncol, data, readerDimnames(null, y));\n }\n requireRows(q, y.length);\n return read(y);\n}\n\n/** Row names given, column names of `y`; null when there are neither. */\nfunction readerDimnames(rows: readonly string[] | null, y: Matrix): Dimnames | null {\n const columns = y.dimnames?.[1] ?? null;\n return rows === null && columns === null ? null : [rows, columns];\n}\n\n/** Apply the reflectors to a copy of `y`, first to last for `Qᵀy`, last to first for `Qy`. */\nfunction transformed(q: QrDecomposition, y: Vector, transpose: boolean): number[] {\n const result = [...y];\n const count = reflectorCount(q);\n if (transpose) {\n for (let step = 0; step < count; step++) {\n applyReflector(q, step, result);\n }\n } else {\n for (let step = count - 1; step >= 0; step--) {\n applyReflector(q, step, result);\n }\n }\n return result;\n}\n\n/**\n * The orthogonal factor, R's `qr.Q(qr)`: `n` rows by `min(n, p)` columns —\n * `Q` applied to the leading columns of the identity. It carries no names,\n * as R's does not.\n */\nexport function qrQ(q: QrDecomposition): Matrix {\n const { nrow, ncol } = q.qr;\n const width = Math.min(nrow, ncol);\n const data = new Float64Array(nrow * width);\n for (let j = 0; j < width; j++) {\n const unit = new Array<number>(nrow).fill(0);\n unit[j] = 1;\n data.set(transformed(q, unit, false), j * nrow);\n }\n return make(nrow, width, data, null);\n}\n\n/**\n * The triangular factor, R's `qr.R(qr)`: `min(n, p)` rows by `p` columns,\n * the upper triangle of the compact form, with the leading row names and\n * the column names in pivot order.\n */\nexport function qrR(q: QrDecomposition): Matrix {\n const { nrow, ncol } = q.qr;\n const height = Math.min(nrow, ncol);\n const data = new Float64Array(height * ncol);\n for (let j = 0; j < ncol; j++) {\n for (let i = 0; i <= Math.min(j, height - 1); i++) {\n data[j * height + i] = q.qr.data[j * nrow + i] as number;\n }\n }\n const rows = q.qr.dimnames?.[0]?.slice(0, height) ?? null;\n const columns = q.qr.dimnames?.[1] ?? null;\n return make(height, ncol, data, rows === null && columns === null ? null : [rows, columns]);\n}\n\n/** Refuse a response that does not match the rows. R's own wording. */\nfunction requireRows(q: QrDecomposition, rows: number): void {\n if (rows !== q.qr.nrow) {\n throw new RangeError(\"'qr' and 'y' must have the same number of rows\");\n }\n}\n\n/**\n * How many reflectors `dqrsl` applies: `min(k, n - 1)`, because the last\n * row of a square or wide matrix is never reflected.\n */\nfunction reflectorCount(q: QrDecomposition): number {\n return Math.min(q.rank, q.qr.nrow - 1);\n}\n\n/**\n * Apply one stored reflector to a vector in place: one step of LINPACK's\n * `dqrsl`.\n *\n * The reflector's leading entry lives in `qraux`, outside the column, so the\n * inner product and the update read it separately from the entries under\n * the diagonal. Both are BLAS calls in LINPACK — `ddot` and `daxpy` — and on\n * the build the fixtures come from each product is contracted into a fused\n * multiply-add, so `fusedMultiplyAdd` is used where the BLAS would round\n * once.\n */\nfunction applyReflector(\n q: QrDecomposition,\n step: number,\n vector: number[],\n): void {\n const leading = q.qraux[step] as number;\n if (leading === 0) {\n return;\n }\n const { nrow } = q.qr;\n const column = q.qr.data.subarray(step * nrow, (step + 1) * nrow);\n\n let inner = leading * (vector[step] as number);\n for (let row = step + 1; row < nrow; row++) {\n inner = fusedMultiplyAdd(column[row] as number, vector[row] as number, inner);\n }\n const factor = -inner / leading;\n vector[step] = fusedMultiplyAdd(factor, leading, vector[step] as number);\n for (let row = step + 1; row < nrow; row++) {\n vector[row] = fusedMultiplyAdd(factor, column[row] as number, vector[row] as number);\n }\n}\n\n/**\n * Factor the columns in place: LINPACK's `dqrdc2`, R's modification of\n * `dqrdc` with limited column pivoting.\n *\n * The routine walks the columns left to right, keeping in `qraux` a running\n * norm of each column's remaining part — downdated after every reflection\n * rather than recomputed, and recomputed only when the downdate would lose\n * too much (the `1e-6` rule). A column whose running norm has fallen below\n * `tolerance` times its original norm moves to the right edge and the\n * columns behind it shift left, so the columns that survive keep their\n * original order — which is why R can report the coefficients of a rank-\n * deficient fit in their own slots, with `NA` in the slot of the column it\n * dropped.\n *\n * On return each column holds its part of R above the diagonal and the\n * Householder vector below it, `qraux` holds the leading entry of each\n * reflector — or, for a column that was never reflected, its running norm,\n * which is what R reports there.\n *\n * @returns `qraux`, the column order, and the rank.\n */\nfunction decompose(\n columns: number[][],\n tolerance: number,\n rows: number,\n): { householders: number[]; pivot: number[]; rank: number } {\n const width = columns.length;\n const pivot = columns.map((_, column) => column);\n const qraux = columns.map((column) => norm(column, 0));\n // `work(j, 1)`: the norm the running value was last set from.\n const lastNorms = [...qraux];\n // `work(j, 2)`: the original norm, with 1 substituted for zero so that an\n // all-zero column compares as negligible rather than dividing by zero.\n const originalNorms = qraux.map((value) => value || 1);\n // R's `k`, one past the count of columns still in play.\n let k = width + 1;\n\n for (let step = 0; step < Math.min(rows, width); step++) {\n // Cycle the columns from `step` rightward until one with a non-negligible\n // norm is found. `step + 1` is R's one-based `l`.\n while (\n step + 1 < k &&\n (qraux[step] as number) < (originalNorms[step] as number) * tolerance\n ) {\n moveToEnd(columns, step);\n moveToEnd(pivot, step);\n moveToEnd(qraux, step);\n moveToEnd(lastNorms, step);\n moveToEnd(originalNorms, step);\n k -= 1;\n }\n\n // The last row leaves nothing to reflect. R skips it and keeps the entry\n // as it stands, which is how a design with more columns than rows still\n // resolves the coefficients it can.\n if (step === rows - 1) {\n continue;\n }\n reflect(columns, qraux, lastNorms, step, rows);\n }\n\n return { householders: qraux, pivot, rank: Math.min(k - 1, rows) };\n}\n\n/**\n * Build the Householder reflector of one column, apply it to the columns to\n * its right, and downdate their running norms. On return `qraux[step]` holds\n * the reflector's leading entry.\n */\nfunction reflect(\n columns: number[][],\n qraux: number[],\n lastNorms: number[],\n step: number,\n rows: number,\n): void {\n const column = columns[step] as number[];\n const length = norm(column, step);\n if (length === 0) {\n return;\n }\n // Reflect away from the leading entry, so that nothing cancels.\n const pivotNorm = (column[step] as number) < 0 ? -length : length;\n\n // `dscal(n, 1/nrmxl, x)`: LINPACK multiplies by the reciprocal rather than\n // dividing, and the two round differently. Dividing lands one ulp away from\n // R in the Householder vector of the very first fixture.\n const reciprocal = 1 / pivotNorm;\n for (let row = step; row < rows; row++) {\n column[row] = (column[row] as number) * reciprocal;\n }\n const leading = 1 + (column[step] as number);\n column[step] = leading;\n\n for (let index = step + 1; index < columns.length; index++) {\n const other = columns[index] as number[];\n // `ddot` and `daxpy`, each product rounded once with its addition.\n let inner = 0;\n for (let row = step; row < rows; row++) {\n inner = fusedMultiplyAdd(column[row] as number, other[row] as number, inner);\n }\n const factor = -inner / leading;\n for (let row = step; row < rows; row++) {\n other[row] = fusedMultiplyAdd(factor, column[row] as number, other[row] as number);\n }\n\n // Downdate the running norm of the column just updated, or recompute it\n // when the downdate would cancel too much.\n const running = qraux[index] as number;\n if (running !== 0) {\n const ratio = Math.abs(other[step] as number) / running;\n const remaining = Math.max(1 - ratio * ratio, 0);\n if (Math.abs(remaining) < 1e-6) {\n qraux[index] = norm(other, step + 1);\n lastNorms[index] = qraux[index] as number;\n } else {\n qraux[index] = running * Math.sqrt(remaining);\n }\n }\n }\n\n qraux[step] = leading;\n column[step] = -pivotNorm;\n}\n\n/**\n * Solve the leading `rank` columns of the triangular system, as `dqrsl`\n * does: column by column from the last, each solved coefficient subtracted\n * from the entries above it with `daxpy`.\n */\nfunction backSubstitute(\n compact: Matrix,\n response: Vector,\n rank: number,\n): number[] {\n const { nrow } = compact;\n const entry = (i: number, j: number): number =>\n compact.data[j * nrow + i] as number;\n const solved = response.slice(0, rank);\n\n for (let column = rank - 1; column >= 0; column--) {\n const value = (solved[column] as number) / entry(column, column);\n solved[column] = value;\n for (let row = 0; row < column; row++) {\n solved[row] = fusedMultiplyAdd(-value, entry(row, column), solved[row] as number);\n }\n }\n\n return solved;\n}\n\n/** Move one entry of an array to its end, sliding the rest left. */\nfunction moveToEnd<T>(track: T[], from: number): void {\n const [moved] = track.splice(from, 1) as [T];\n track.push(moved);\n}\n\n/**\n * The Euclidean length of a column from `from` down: the BLAS `dnrm2`.\n *\n * For values in the ordinary range `dnrm2` is a sum of squares under a\n * square root; its scaling engages only near overflow or underflow, which\n * no fixture and no teaching dataset reaches. Written as a fold —\n * `Math.hypot(...column)` overflows the call stack past about a million\n * entries, and its rounding is not specified — with each square rounded\n * once into the sum, as the contracted BLAS does.\n */\nfunction norm(column: Vector, from: number): number {\n let squares = 0;\n for (let row = from; row < column.length; row++) {\n const value = column[row] as number;\n squares = fusedMultiplyAdd(value, value, squares);\n }\n return Math.sqrt(squares);\n}\n",
|
|
20
|
+
"/**\n * R's `lm()` over a data frame, with what `summary.lm()` reads off the fit.\n *\n * `lm()` is `model.matrix()` followed by `lm.fit()`, and `lm.fit()` is\n * `dqrls`: the `qr()` of `qr.ts` — LINPACK's `dqrdc2` with its limited\n * column pivoting — followed by `dqrsl`'s coefficients and residuals, with\n * the fitted values as `y` minus the residuals. The port runs that same\n * arithmetic, so the coefficients, fitted values and residuals pin bit for\n * bit against R. The summary statistics — R², adjusted R², σ, the standard\n * errors and the t and p values — follow `summary.lm()`'s formulas but not\n * its rounding step for step (`chol2inv` and `pt`), and are verified at a\n * stated tolerance. See `lm.test.ts`.\n *\n * Coefficients come back as a `NamedVector` in R's order, `null` where R\n * reports `NA` for an aliased column. Fitted values and residuals are padded\n * with NaN to the input length where a row was dropped for a missing value,\n * R's `na.exclude`, which is the convention every fit in this package uses.\n */\n\nimport { mean, sum, zipWith } from \"../arith\";\nimport type { DataFrame } from \"../frame\";\nimport { pt } from \"../tdist\";\nimport { modelMatrix, type ModelSpec } from \"./modelMatrix\";\nimport { namedVector, type NamedVector } from \"./namedVector\";\nimport { DEFAULT_QR_TOLERANCE, qr, qrCoef, qrResid, type QrDecomposition } from \"./qr\";\nimport type { Vector } from \"./vector\";\n\n/** The model, with the outcome required, and the rank tolerance. */\nexport interface LmOptions extends ModelSpec {\n /** The column to fit. */\n readonly outcome: string;\n /** How far a column's norm may collapse before it is aliased. R's `lm.fit()` default. */\n readonly tolerance?: number;\n}\n\n/** R's `summary(fit)$fstatistic`. */\nexport interface FStatistic {\n readonly value: number;\n readonly numdf: number;\n readonly dendf: number;\n}\n\n/** A fitted linear model and its summary. */\nexport interface LmFit {\n /** `coef(fit)`: one entry per design column, null where R reports `NA`. */\n readonly coefficients: NamedVector;\n /** `coef(summary(fit))[, \"Std. Error\"]`, null for an aliased term. */\n readonly standardErrors: NamedVector;\n /** `coef(summary(fit))[, \"t value\"]`, null for an aliased term. */\n readonly tValues: NamedVector;\n /** `coef(summary(fit))[, \"Pr(>|t|)\"]`, null for an aliased term. */\n readonly pValues: NamedVector;\n /** The fitted outcome of each data row, in input order; NaN for a row dropped. */\n readonly fitted: Vector;\n /** The outcome minus the fit, in input order; NaN for a row dropped. */\n readonly residuals: Vector;\n /** The number of columns the fit could identify. */\n readonly rank: number;\n /** `fit$df.residual`: rows fitted minus rank. */\n readonly dfResidual: number;\n /** `summary(fit)$r.squared`. */\n readonly rSquared: number;\n /** `summary(fit)$adj.r.squared`. */\n readonly adjRSquared: number;\n /** `summary(fit)$sigma`: the residual standard error. */\n readonly sigma: number;\n /** `summary(fit)$fstatistic`, or null when the model has no term beyond the intercept. */\n readonly fStatistic: FStatistic | null;\n /** The data rows the fit used, in input order. */\n readonly rows: readonly number[];\n /** R's `term.labels`. */\n readonly termLabels: readonly string[];\n}\n\n/**\n * Fit a linear model, as R's `lm()` does.\n *\n * @param data The frame holding every column the model names.\n * @param options The outcome, the terms, the intercept flag, and the rank\n * tolerance.\n * @returns The fit and its summary.\n * @throws RangeError If a named column is absent or not numeric, if the\n * frame is ragged, or if no row is complete — R's \"0 (non-NA) cases\".\n */\nexport function lm(data: DataFrame, options: LmOptions): LmFit {\n const { outcome, intercept = true, tolerance = DEFAULT_QR_TOLERANCE } = options;\n const design = modelMatrix(data, options);\n const { rows } = design;\n const n = rows.length;\n if (n === 0) {\n throw new RangeError(\"0 (non-NA) cases\");\n }\n // modelMatrix has already checked the outcome column.\n const outcomeColumn = data[outcome] as Vector;\n const y = rows.map((row) => outcomeColumn[row] as number);\n\n const factored = qr(design.matrix, { tolerance });\n const coefficients = qrCoef(factored, y);\n const residuals = qrResid(factored, y);\n const fitted = zipWith(y, residuals, (value, residual) => value - residual);\n const names = design.matrix.dimnames?.[1] ?? [];\n\n const { rank } = factored;\n const dfResidual = n - rank;\n const interceptCount = intercept ? 1 : 0;\n const rss = sum(residuals.map((r) => r * r));\n const centered = intercept ? mean(fitted) : 0;\n const mss = sum(fitted.map((f) => (f - centered) * (f - centered)));\n const resvar = rss / dfResidual;\n const numdf = rank - interceptCount;\n // summary.lm() reports 0 for both when nothing beyond the intercept was\n // fitted, rather than the rounding noise the formula would give.\n const rSquared = numdf > 0 ? mss / (mss + rss) : 0;\n const adjRSquared =\n numdf > 0 ? 1 - (1 - rSquared) * ((n - interceptCount) / dfResidual) : 0;\n\n const standardErrors = standardErrorsOf(factored, resvar, names.length);\n const tValues = zipWith(coefficients, standardErrors, (b, se) =>\n b === null || se === null ? null : b / se,\n );\n const pValues = tValues.map((tv) =>\n tv === null ? null : 2 * pt(-Math.abs(tv), dfResidual),\n );\n\n return {\n coefficients: namedVector(names, coefficients),\n standardErrors: namedVector(names, standardErrors),\n tValues: namedVector(names, tValues),\n pValues: namedVector(names, pValues),\n fitted: padded(fitted, rows, outcomeColumn.length),\n residuals: padded(residuals, rows, outcomeColumn.length),\n rank,\n dfResidual,\n rSquared,\n adjRSquared,\n sigma: Math.sqrt(resvar),\n fStatistic:\n numdf > 0 ? { value: mss / numdf / resvar, numdf, dendf: dfResidual } : null,\n rows,\n termLabels: design.termLabels,\n };\n}\n\n/**\n * The standard errors, `summary.lm()`'s `sqrt(diag(chol2inv(R)) * resvar)`\n * over the leading `rank` columns of the factorization, placed back in the\n * original column order; null for an aliased column.\n *\n * `chol2inv(R)` is `(RᵀR)⁻¹ = R⁻¹ R⁻ᵀ`, whose diagonal is the sum of\n * squares of each row of `R⁻¹`. `R⁻¹` comes from back substitution against\n * the identity.\n */\nfunction standardErrorsOf(\n factored: QrDecomposition,\n resvar: number,\n width: number,\n): (number | null)[] {\n const { rank, pivot } = factored;\n const { nrow } = factored.qr;\n const r = (i: number, j: number): number => factored.qr.data[j * nrow + i] as number;\n\n // Column k of R⁻¹ solves R x = e_k; the entries above row k are the only\n // ones that can be non-zero.\n const inverse = Array.from({ length: rank }, (_, k) => {\n const x = new Array<number>(rank).fill(0);\n x[k] = 1 / r(k, k);\n for (let i = k - 1; i >= 0; i--) {\n let total = 0;\n for (let j = i + 1; j <= k; j++) {\n total += r(i, j) * (x[j] as number);\n }\n x[i] = -total / r(i, i);\n }\n return x;\n });\n const diagonal = Array.from({ length: rank }, (_, i) =>\n sum(inverse.map((columnOfInverse) => (columnOfInverse[i] as number) ** 2)),\n );\n\n const errors = new Array<number | null>(width).fill(null);\n pivot.slice(0, rank).forEach((original, position) => {\n errors[original] = Math.sqrt((diagonal[position] as number) * resvar);\n });\n return errors;\n}\n\n/** Spread values fitted on `rows` back over `length` slots, NaN elsewhere. */\nfunction padded(values: Vector, rows: readonly number[], length: number): number[] {\n const out = new Array<number>(length).fill(Number.NaN);\n rows.forEach((row, index) => {\n out[row] = values[index] as number;\n });\n return out;\n}\n",
|
|
21
|
+
"/**\n * The fitted surface of a moderated regression.\n *\n * This is the statistics half of `plot_moderation_3d()` in the R package,\n * which fits `lm(formula, data)`, predicts over a 15 by 15 grid of the IV and\n * the moderator, and hands the grid to `lattice::wireframe()`. Verified\n * against R in `moderation.test.ts`.\n *\n * Four things are worth knowing before reading the code.\n *\n * **Columns, not a formula.** R names the model with `y ~ x * z`. TypeScript\n * has no such notation, so the model arrives as column names, per CLAUDE.md:\n * an outcome, an IV, a moderator, an optional list of controls, and a flag\n * for the interaction. The three models the fixtures pin are\n * `{outcome: \"y\", iv: \"x\", mod: \"z\"}` (R's `y ~ x * z`), the same with\n * `interaction: false` (`y ~ x + z`), and the same with `controls: [\"w\"]`\n * (`y ~ x + z + w + x:z`).\n *\n * **The design follows R's model matrix, not the option order.** R's\n * `model.matrix` puts every main effect before any interaction, whatever\n * order the formula was typed in, so `y ~ x + z + w + x:z` gives the columns\n * `(Intercept), x, z, w, x:z`. This module names the terms and hands them to\n * `linalg/lm`, which is `model.matrix()` followed by `lm.fit()` and puts the\n * columns in that order, so a caller can read the coefficients next to R's.\n * Going through `lm` also makes the fitted values `y` minus the residuals of\n * the factorization, which is R's own definition, rather than `X · β`.\n *\n * **Controls are held at their mean, and only numbers are accepted.** R's\n * `hold_value()` also handles factors (first level), characters (first in\n * sort order) and logicals (always FALSE). The bundled data has no such\n * column and no doc example uses one, so this port supports the numeric\n * branch alone and refuses the rest, rather than shipping three rules nothing\n * exercises. The other rules are recorded in\n * `.claude/plans/001-PLAN-port/moderation-fixtures.md` section 4 if they are ever wanted.\n *\n * **Missing values leave the fit, as R's do.** `lm()` drops incomplete rows\n * through `na.omit` and `hold_value()` averages with `na.rm = TRUE`; this\n * port does the same, with NaN standing in for `NA` and any non-finite value\n * counting as missing. The details — the `na.exclude`-style NaN padding of\n * `fitted` and `residuals`, the one departure on `zlim` — are on\n * `moderationSurface` itself.\n */\n\nimport { extent, mean, sum, zipWith } from \"./arith\";\nimport { frameRows, requireNumericColumn, type DataFrame } from \"./frame\";\nimport { lm } from \"./linalg/lm\";\n\n/**\n * The number of steps along each axis of the grid. R's\n * `plot_moderation_3d()` hardcodes `length.out = 15` for both.\n */\nconst GRID_STEPS = 15;\n\n/** Which columns make the model. */\nexport interface ModerationOptions {\n /** The column to predict — the vertical axis of the surface. */\n readonly outcome: string;\n /** The predictor on the first horizontal axis. */\n readonly iv: string;\n /** The predictor on the second horizontal axis. */\n readonly mod: string;\n /**\n * Whether the model carries the IV by moderator product. True by default,\n * which is R's `y ~ x * z`. False gives R's additive `y ~ x + z`, whose\n * surface is a plane with no twist.\n */\n readonly interaction?: boolean;\n /**\n * Further predictors to fit but not to plot. Each is held at its own mean\n * over the grid, R's `hold_value()` for a numeric column. Empty by default.\n */\n readonly controls?: readonly string[];\n}\n\n/** One fitted term, named as R names it. */\nexport interface ModerationTerm {\n /**\n * R's coefficient name: `(Intercept)`, a column name, or `iv:mod` for the\n * product term.\n */\n readonly name: string;\n /**\n * The coefficient, or null where R reports `NA` — a column the fit could\n * not tell apart from the columns before it.\n */\n readonly value: number | null;\n}\n\n/** A fitted model and the surface it predicts. */\nexport interface ModerationSurface {\n /** The fitted terms, in R's model-matrix order. */\n readonly coefficients: readonly ModerationTerm[];\n /**\n * The fitted outcome of each data row, in input order. NaN where the row\n * was dropped for a missing value, as R's `na.exclude` pads.\n */\n readonly fitted: readonly number[];\n /**\n * The outcome minus the fit, of each data row, in input order. NaN where\n * the row was dropped for a missing value.\n */\n readonly residuals: readonly number[];\n /** The 15 IV values of the grid, from the column's minimum to its maximum. */\n readonly ivValues: readonly number[];\n /** The 15 moderator values of the grid, over the same span. */\n readonly modValues: readonly number[];\n /**\n * The 225 predicted outcomes, **with the IV varying fastest**: index\n * `j * 15 + i` holds the prediction at `ivValues[i]` and `modValues[j]`.\n * This is the row order of R's `expand.grid(seq_iv, seq_mod)`.\n */\n readonly predictions: readonly number[];\n /**\n * The vertical range to draw, as `[low, high]`: the range of the observed\n * outcome together with the range of the surface. Which of the two reaches\n * further depends on the model — an interaction usually swings the surface\n * past the data at the corners of the grid, while a plane stays inside it.\n */\n readonly zlim: readonly [number, number];\n /** The value each control is held at over the grid: its mean. */\n readonly holds: Readonly<Record<string, number>>;\n}\n\n/**\n * Fit the model and predict its surface.\n *\n * Rows with a missing (non-finite) value in any model column are dropped\n * before fitting, R's `na.action = na.omit`; their fitted values and\n * residuals report NaN, keeping input order. The grid and zlim span the\n * finite values of their columns, and a control is held at its finite mean —\n * R's `hold_value()` with `na.rm = TRUE`. (R itself computes zlim with no\n * `na.rm` and fails on a missing outcome; the port draws what it can fit, a\n * stated departure.)\n *\n * @param data The frame holding every column the options name.\n * @param options Which column plays which part in the model.\n * @returns The fit, the grid, the surface, and the vertical range.\n * @throws RangeError If a named column is absent, empty, or not numeric, if\n * the IV and the moderator are the same column, if a control repeats\n * another named column, if the frame is ragged, or if no row is complete.\n */\nexport function moderationSurface(\n data: DataFrame,\n options: ModerationOptions,\n): ModerationSurface {\n const { outcome, iv, mod, interaction = true, controls = [] } = options;\n\n if (iv === mod) {\n throw new RangeError(\n `\\`iv\\` and \\`mod\\` must name different columns, both name \"${iv}\"`,\n );\n }\n // A repeated column would enter the design twice and alias itself, and the\n // caller would read a null coefficient with no clue why.\n const named = new Set([outcome, iv, mod]);\n controls.forEach((control) => {\n if (named.has(control)) {\n throw new RangeError(\n `control \"${control}\" already names the outcome, the iv, the mod, ` +\n \"or another control\",\n );\n }\n named.add(control);\n });\n\n // `lm` validates the frame again through `modelMatrix`, but reading the\n // columns here first is what lets the refusals below name the option the\n // column arrived through.\n frameRows(data);\n const y = requireNumericColumn(data, outcome, \"outcome\");\n const ivColumn = requireNumericColumn(data, iv, \"iv\");\n const modColumn = requireNumericColumn(data, mod, \"mod\");\n const controlColumns = controls.map((control) =>\n requireNumericColumn(data, control, \"controls\"),\n );\n\n // R's na.omit: a row with a missing value in any model column leaves the\n // fit. NaN is this library's missing value, and an infinity would poison\n // the fit the same way, so \"complete\" means finite everywhere. `lm` drops\n // the same rows and refuses an empty fit in R's words, \"0 (non-NA) cases\";\n // the check is repeated here only to name the columns that can be at\n // fault, which a caller who chose them one by one needs.\n const modelColumns = [y, ivColumn, modColumn, ...controlColumns];\n const anyComplete = y.some((_, row) =>\n modelColumns.every((column) => Number.isFinite(column[row])),\n );\n if (!anyComplete) {\n throw new RangeError(\n \"the model has no complete rows: every row is missing a value in \" +\n \"the outcome, the IV, the moderator, or a control\",\n );\n }\n\n // R's `y ~ x * z + w` as a term list: the main effects as the model names\n // them, then the product. `lm` restores R's column order, drops the\n // incomplete rows and pads the fit back with NaN (`na.exclude`).\n const fit = lm(data, {\n outcome,\n terms: [iv, mod, ...controls, ...(interaction ? [[iv, mod]] : [])],\n });\n const { fitted, residuals } = fit;\n const coefficients = fit.coefficients.names.map((name, index) => ({\n name,\n value: fit.coefficients.values[index] ?? null,\n }));\n\n // extent() ignores non-finite values, so each axis spans its column's\n // finite range — R's seq over min and max, which R only reaches when the\n // column has no NA. The hold is R's hold_value(): mean with na.rm = TRUE.\n const ivValues = rSeq(...extent(ivColumn), GRID_STEPS);\n const modValues = rSeq(...extent(modColumn), GRID_STEPS);\n const holds = Object.fromEntries(\n controls.map((control, index) => [\n control,\n mean(\n (controlColumns[index] as readonly number[]).filter(Number.isFinite),\n ),\n ]),\n );\n\n // R's predict() drops an aliased term rather than giving up on the row, so\n // a null coefficient contributes nothing here either.\n const weights = coefficients.map((term) => term.value ?? 0);\n const predictions = modValues.flatMap((modValue) =>\n ivValues.map((ivValue) => {\n const gridRow = [\n 1,\n ivValue,\n modValue,\n ...controls.map((control) => holds[control] as number),\n ...(interaction ? [ivValue * modValue] : []),\n ];\n return sum(zipWith(gridRow, weights, (value, weight) => value * weight));\n }),\n );\n\n const [dataLow, dataHigh] = extent(y);\n const [surfaceLow, surfaceHigh] = extent(predictions);\n\n return {\n coefficients,\n fitted,\n residuals,\n ivValues,\n modValues,\n predictions,\n zlim: [Math.min(dataLow, surfaceLow), Math.max(dataHigh, surfaceHigh)],\n holds,\n };\n}\n\n/**\n * Step from one end of a span to the other, the way R's\n * `seq(from, to, length.out = n)` does.\n *\n * R computes `from + i * by` in plain double arithmetic and writes both\n * endpoints in exactly. That last part matters — it is why the grid always\n * reaches the data's own minimum and maximum — and so does the plain\n * arithmetic: rounding the product and the sum together, as `pretty.ts` must\n * for R's other sequence path, moves 14 of the 30 grid coordinates of the\n * bundled dataset off R's values.\n *\n * @param from The first value.\n * @param to The last value.\n * @param length How many values to return.\n * @returns The sequence. A span of no width repeats its one value, as R's\n * `seq(3, 3, length.out = 15)` does.\n */\nfunction rSeq(from: number, to: number, length: number): number[] {\n if (from === to) {\n return new Array<number>(length).fill(from);\n }\n\n const by = (to - from) / (length - 1);\n return Array.from({ length }, (_, index) =>\n index === 0 ? from : index === length - 1 ? to : from + index * by,\n );\n}\n",
|
|
22
|
+
"/**\n * The moderation surface: a fitted regression drawn as a height field over\n * the IV and the moderator.\n *\n * This is the drawing half of `plot_moderation_3d()` of\n * `../compstatslib/R/moderation_3d_plot.R`. Every number comes from\n * `moderationSurface` in `src/core/moderation.ts`; this module computes no\n * statistics of its own. The grid values are pinned in\n * `.claude/plans/001-PLAN-port/moderation-fixtures.md` section 3.\n *\n * Three decisions are worth stating.\n *\n * **The engine is Plotly, not lattice.** R draws this surface with\n * `lattice::wireframe(drape = TRUE, colorkey = FALSE)`, which colors the mesh\n * by height and hides the key. A Plotly surface is colored by height already,\n * so the port sets `showscale: false` and keeps the rest. The colors\n * themselves are Plotly's, not lattice's: a browser has no lattice palette,\n * and the teaching point of the picture is the twist of the surface, not its\n * hue.\n *\n * **The rotation arguments become a camera, approximately.** Lattice takes\n * `screen = list(z = z_rot, x = x_rot)`, two rotations of the data. Plotly\n * takes a camera position. `cameraFromRotations` maps one onto the other, and\n * says how.\n *\n * **The vertical axis carries the outcome.** With the bundled data the\n * moderator is named `z` and it is drawn on a horizontal axis, while the\n * outcome `y` stands up. R's help makes the same point, twice.\n */\n\nimport { moderationSurface } from \"../core/moderation\";\nimport type { ModerationOptions, ModerationSurface } from \"../core/moderation\";\nimport type { DataFrame } from \"../core/frame\";\nimport { loadPlotly } from \"./plotly\";\nimport type {\n EyeCamera,\n PlotlyHTMLElement,\n PlotlyLayout,\n PlotlyLike,\n SurfaceTrace,\n Vector3,\n} from \"./plotly\";\n\n/** R's `z_rot = 40`: the turn about the vertical axis, in degrees. */\nconst DEFAULT_Z_ROT = 40;\n/** R's `x_rot = -70`: the tilt, in degrees. */\nconst DEFAULT_X_ROT = -70;\n/**\n * How far the camera stands from the middle of the scene. This is the length\n * of Plotly's own default eye, `(1.25, 1.25, 1.25)`, so a plot that sets a\n * camera opens at the same distance as one that does not.\n */\nconst EYE_DISTANCE = 1.25 * Math.sqrt(3);\n/** The name Plotly keeps the view under, across every redraw. */\nconst UIREVISION = \"moderation3d\";\n/** Plotly redraws the plot when the element that holds it changes size. */\nconst CONFIG = { responsive: true } as const;\n\n/** How to look at the surface. */\nexport interface Moderation3dViewOptions {\n /**\n * The turn about the vertical axis, in degrees. R's `z_rot`, 40 by default.\n * 0 lays the IV across the screen; 270 lays the moderator across it.\n */\n readonly zRot?: number;\n /**\n * The tilt, in degrees. R's `x_rot`, −70 by default. −90 looks along the\n * floor of the plot, and the view rises towards 0.\n */\n readonly xRot?: number;\n /**\n * The values the vertical axis spans, as `[low, high]`. The range of the\n * data together with the range of the surface by default, which is R's own\n * rule and what `moderationSurface` reports as `zlim`.\n */\n readonly zlim?: readonly [number, number];\n}\n\n/** The options of `plotModeration3d`: the model, the view, and the engine. */\nexport interface PlotModeration3dOptions\n extends ModerationOptions,\n Moderation3dViewOptions {\n /**\n * The Plotly engine. `loadPlotly()` by default, which fetches the library on\n * first use.\n */\n readonly plotly?: PlotlyLike;\n}\n\n/** What a surface and a set of view options draw. */\nexport interface Moderation3dSpec {\n /** The one height field. */\n readonly traces: readonly SurfaceTrace[];\n readonly layout: PlotlyLayout;\n /**\n * What R says in its `message()` when predictors are held off the axes.\n * Null when every predictor of the model is drawn.\n */\n readonly note: string | null;\n}\n\n/** A drawn surface: its specification, its fit, its element, and its engine. */\nexport interface Moderation3dHandle extends Moderation3dSpec {\n /** The element Plotly drew into, with its event emitter attached. */\n readonly element: PlotlyHTMLElement;\n /** The engine that drew, ready for the next redraw and for teardown. */\n readonly plotly: PlotlyLike;\n /** The fit and the grid behind the picture. */\n readonly surface: ModerationSurface;\n}\n\n/**\n * Place the camera for a pair of lattice rotations.\n *\n * This is a visual approximation, not an equivalence: lattice rotates the data\n * and Plotly moves the camera, and the two pictures agree in direction, not\n * pixel for pixel. The mapping is\n *\n * ```text\n * azimuth = -90 - zRot degrees\n * elevation = 90 + xRot degrees\n * eye = distance * (cos elevation * cos azimuth,\n * cos elevation * sin azimuth,\n * sin elevation)\n * ```\n *\n * Both anchors of R's own help hold under it. At `zRot = 0` the camera stands\n * on the moderator axis, so the IV runs across the screen and the IV slope\n * plane faces the viewer; at `zRot = 270` the camera stands on the IV axis and\n * the moderator plane faces it. The tilt reads the same way as lattice's: at\n * `xRot = -90` the camera is level with the floor of the plot, and R's default\n * −70 lifts it 20 degrees above it.\n *\n * @param zRot The turn about the vertical axis, in degrees.\n * @param xRot The tilt, in degrees.\n * @returns The camera, as Plotly's `scene.camera`.\n * @throws RangeError If either angle is not a finite number, which would\n * place the camera nowhere.\n */\nexport function cameraFromRotations(zRot: number, xRot: number): EyeCamera {\n if (!Number.isFinite(zRot) || !Number.isFinite(xRot)) {\n throw new RangeError(\"`zRot` and `xRot` must be finite numbers.\");\n }\n\n const azimuth = ((-90 - zRot) * Math.PI) / 180;\n const elevation = ((90 + xRot) * Math.PI) / 180;\n const eye: Vector3 = {\n x: EYE_DISTANCE * Math.cos(elevation) * Math.cos(azimuth),\n y: EYE_DISTANCE * Math.cos(elevation) * Math.sin(azimuth),\n z: EYE_DISTANCE * Math.sin(elevation),\n };\n\n return { eye };\n}\n\n/**\n * Build the trace and the layout of a moderation surface.\n *\n * @param surface The fit and the grid, from `moderationSurface`.\n * @param model The columns the surface was fitted over. Their names title the\n * axes, and the controls decide whether there is a note.\n * @param view How to look at the surface.\n * @returns The trace, the layout, and the note about held predictors.\n * @throws RangeError If a rotation is not finite, if a given vertical range is\n * not two finite numbers, or if any height of the surface is not finite —\n * a non-finite height would crash the WebGL engine for the whole page.\n */\nexport function moderation3dSpec(\n surface: ModerationSurface,\n model: ModerationOptions,\n view: Moderation3dViewOptions = {},\n): Moderation3dSpec {\n const { zRot = DEFAULT_Z_ROT, xRot = DEFAULT_X_ROT, zlim } = view;\n const camera = cameraFromRotations(zRot, xRot);\n\n if (zlim !== undefined) {\n if (zlim.length !== 2 || !zlim.every((value) => Number.isFinite(value))) {\n throw new RangeError(\"`zlim` must be two finite numbers.\");\n }\n }\n const range: readonly [number, number] = zlim ?? [\n surface.zlim[0],\n surface.zlim[1],\n ];\n\n // Plotly reads a height field row by row along y, so each row of z holds one\n // moderator value and runs across the IV. That is R's own grid order, the IV\n // varying fastest: index j * 15 + i.\n const steps = surface.ivValues.length;\n const heights = surface.modValues.map((_, j) =>\n surface.ivValues.map((__, i) => surface.predictions[j * steps + i] as number),\n );\n\n // A NaN in the height field does not fail politely: it crashes WebGL inside\n // plotly.js, and every surface drawn on the page afterwards fails too.\n // Refuse here so that no caller can poison the engine.\n if (!surface.predictions.every(Number.isFinite)) {\n throw new RangeError(\n \"the surface must have finite heights everywhere; \" +\n \"a prediction is NaN or infinite\",\n );\n }\n\n const trace: SurfaceTrace = {\n type: \"surface\",\n x: surface.ivValues,\n y: surface.modValues,\n z: heights,\n // R's `colorkey = FALSE`.\n showscale: false,\n };\n\n const layout: PlotlyLayout = {\n uirevision: UIREVISION,\n scene: {\n xaxis: { title: { text: model.iv } },\n yaxis: { title: { text: model.mod } },\n zaxis: { title: { text: model.outcome }, range },\n uirevision: UIREVISION,\n camera,\n },\n };\n\n return { traces: [trace], layout, note: describeHolds(model) };\n}\n\n/**\n * Fit the model and draw its surface.\n *\n * @param target The element to draw into. Plotly fills it.\n * @param data The frame holding every column the model names.\n * @param options The model, the view, and the engine.\n * @returns The drawn plot: its element, its specification, its engine, and the\n * surface behind it.\n * @throws RangeError Everything `moderationSurface` and `moderation3dSpec`\n * throw, as a rejected promise. Nothing reaches the engine until the model\n * is fitted and the view is settled.\n */\nexport async function plotModeration3d(\n target: HTMLElement,\n data: DataFrame,\n options: PlotModeration3dOptions,\n): Promise<Moderation3dHandle> {\n const { plotly, zRot, xRot, zlim, ...model } = options;\n const surface = moderationSurface(data, model);\n const spec = moderation3dSpec(surface, model, { zRot, xRot, zlim });\n const engine = plotly ?? (await loadPlotly());\n const element = await engine.react(target, spec.traces, spec.layout, CONFIG);\n\n return { ...spec, element, plotly: engine, surface };\n}\n\n/** R's `describe_holds()`: one sentence, and only when a predictor is held. */\nfunction describeHolds(model: ModerationOptions): string | null {\n if ((model.controls ?? []).length === 0) {\n return null;\n }\n return (\n `Surface shows predicted ${model.outcome} over ${model.iv} and ` +\n `${model.mod}. Other predictors are held at their typical values.`\n );\n}\n",
|
|
16
23
|
"/**\n * The interactive moderation surface: turn the wireframe and watch the twist\n * of the interaction appear and disappear.\n *\n * This is the port of `interactive_moderation_3d()` in\n * `../compstatslib/R/moderation_3d_interactive.R`. R builds a shiny gadget\n * with two rotation sliders and re-runs `plot_moderation_3d()` whenever one\n * moves. This module does the same: it owns the two sliders and hands every\n * draw to `plotModeration3d`. It fits nothing and draws nothing itself.\n *\n * Three things are worth knowing before reading the code.\n *\n * **The sliders are kept, although a browser can drag the camera.** They are\n * what R's help teaches with: \"Try 0 to align the IV slope plane with the\n * screen, or 270 to align the moderator slope plane.\" A free drag cannot name\n * an angle, and those two angles are the lesson. Dragging still works, and\n * the two live together: a drag is preserved until a slider asks for\n * something else.\n *\n * **A slider must push the camera at the plot.** The plot layer sets a\n * constant `uirevision`, which is what keeps a drag across a redraw. Plotly\n * honours it literally: once the user has turned the plot, a later `react`\n * carrying a different `scene.camera` is ignored, because the user's own edit\n * wins. The sliders would then move nothing. So a rotation change is sent\n * after the redraw as a `relayout`, which is an instruction rather than a\n * preference. The alternative — changing the `uirevision` whenever a slider\n * moves — would have to reach into the layout the plot layer owns, and would\n * throw away the drag on every redraw whether or not the view changed.\n * Nothing new is pushed when the rotations have not moved, so a redraw for\n * any other reason leaves the user's own view alone. The one other push this\n * component makes runs the opposite way: a camera the user drags to is\n * written back into Plotly's stored layout (see `handleRelayout`), because\n * the modebar's own buttons relayout the scene from that layout and would\n * otherwise snap the view to the sliders' angles.\n *\n * **Done hands back the current view.** R returns `data`, which the caller\n * already holds and which says nothing about the picture. The rotations do,\n * and together with the model they reopen the same plot — the same choice the\n * t-test component made for the same reason.\n *\n * There is no Reset: R has Done and Cancel only. There is no validation of\n * the model here either. R's gadget opens and lets `plot_moderation_3d()`\n * report a bad column in the plot pane; the port's equivalent is a rejected\n * `rendered()`, so a caller that wants to hear about it must await.\n */\n\nimport type { DataFrame } from \"../core/frame\";\nimport type { ModerationOptions, ModerationSurface } from \"../core/moderation\";\nimport { plotModeration3d } from \"../plot/moderation3d\";\nimport type {\n Moderation3dSpec,\n Moderation3dViewOptions,\n PlotModeration3dOptions,\n} from \"../plot/moderation3d\";\nimport { sameCamera } from \"../plot/plotly\";\nimport type {\n PlotlyCamera,\n PlotlyHTMLElement,\n PlotlyLike,\n PlotlyRelayoutEvent,\n} from \"../plot/plotly\";\nimport { buildNote, buildSlider, startingSliderValue } from \"./controls\";\nimport type { SliderRange } from \"./controls\";\nimport { resolvePlot3dTarget } from \"./target\";\nimport type { Plot3dTarget } from \"./target\";\n\n/**\n * Everything the panel holds: the two rotations, and the model behind the\n * surface. Hand it back to `interactiveModeration3d` or to\n * `plotModeration3d` to reopen the same picture.\n */\nexport interface Moderation3dValues\n extends ModerationOptions,\n Moderation3dViewOptions {\n /** The turn about the vertical axis, in degrees. */\n readonly zRot: number;\n /** The tilt, in degrees. */\n readonly xRot: number;\n}\n\n/**\n * What the component accepts.\n *\n * Every option of `plotModeration3d` is a starting value, and anything the\n * plot grows later reaches it untouched. The model itself — which column is\n * the outcome, the IV and the moderator — is required, as it is by the plot.\n */\nexport interface InteractiveModeration3dOptions\n extends PlotModeration3dOptions {\n /** What to run on `done()`. */\n readonly onDone?: (values: Moderation3dValues) => void;\n}\n\n/** What the caller holds after the component starts. */\nexport interface InteractiveModeration3dHandle {\n /** Return the rotations the sliders stand at, and the model being drawn. */\n getValues(): Moderation3dValues;\n /** Return the fit and the grid behind the last picture. */\n getSurface(): ModerationSurface | null;\n /** Return the traces, the layout, and the note of the last draw. */\n getSpec(): Moderation3dSpec | null;\n /** Wait for the drawing now in flight. Drawing is asynchronous. */\n rendered(): Promise<void>;\n /** Hand the current values to the `onDone` callback. */\n done(): void;\n /** Stop listening, purge the plot, and take back what was built. */\n destroy(): void;\n}\n\n/** R: `sliderInput(\"z_rot\", \"Z rotation\", min = 0, max = 360, value = 40)`. */\nconst Z_ROT_RANGE: SliderRange = { min: 0, max: 360, step: 1 };\n/**\n * R: `sliderInput(\"x_rot\", \"X rotation\", min = -90, max = -70, value = -70)`.\n */\nconst X_ROT_RANGE: SliderRange = { min: -90, max: -70, step: 1 };\n/** R's own starting angles, from the same two `sliderInput` calls. */\nconst DEFAULT_Z_ROT = 40;\nconst DEFAULT_X_ROT = -70;\n\n/** The two sliders, in R's order. */\nconst SLIDERS = [\n {\n name: \"zRot\",\n label: \"Z rotation\",\n range: Z_ROT_RANGE,\n fallback: DEFAULT_Z_ROT,\n },\n {\n name: \"xRot\",\n label: \"X rotation\",\n range: X_ROT_RANGE,\n fallback: DEFAULT_X_ROT,\n },\n] as const;\n\n/**\n * Start an interactive moderation surface on a target.\n *\n * The component builds its two sliders, draws once, and redraws on every\n * change.\n *\n * @param target A container element, or a plot element and a controls host.\n * See `./target.ts`.\n * @param data The frame holding every column the model names.\n * @param options The model, the starting rotations, a done callback, and the\n * options of `plotModeration3d`.\n * @returns The handle to the running component. Await `rendered()` for the\n * first picture, and to hear about a model the data cannot carry.\n * @throws Error If a canvas is passed as the container.\n */\nexport function interactiveModeration3d(\n target: Plot3dTarget,\n data: DataFrame,\n options: InteractiveModeration3dOptions,\n): InteractiveModeration3dHandle {\n // Everything `plotModeration3d` may grow later stays in `model` and reaches\n // it untouched, so a new plot option needs no edit here.\n const { plotly: givenEngine, onDone, zRot, xRot, ...model } = options;\n\n const panel = resolvePlot3dTarget(target);\n const owner = panel.controls.ownerDocument;\n\n let values: Moderation3dValues = {\n ...model,\n zRot: startingSliderValue(zRot, DEFAULT_Z_ROT, Z_ROT_RANGE),\n xRot: startingSliderValue(xRot, DEFAULT_X_ROT, X_ROT_RANGE),\n };\n\n let spec: Moderation3dSpec | null = null;\n let surface: ModerationSurface | null = null;\n let engine: PlotlyLike | undefined = givenEngine;\n let element: PlotlyHTMLElement | null = null;\n /** The rotations the plot was last told to stand at, or null before then. */\n let painted: { readonly zRot: number; readonly xRot: number } | null = null;\n /**\n * The camera this component last put into Plotly's stored layout — by a\n * slider's push or by persisting a drag — or undefined before either. What\n * the capture handler compares against to recognize its own echo.\n */\n let seenCamera: PlotlyCamera | undefined;\n let listening = false;\n let destroyed = false;\n let inFlight: Promise<void> | null = null;\n let queued = false;\n\n const note = buildNote(owner);\n\n /**\n * Draw once, at whatever the sliders stand at now, and move the camera if\n * they ask for a view the plot is not already at.\n *\n * The camera pushed is the one the plot layer computed, read back out of\n * the layout it built. Nothing here works out where a camera goes.\n */\n async function renderOnce(): Promise<void> {\n const wanted = { zRot: values.zRot, xRot: values.xRot };\n const drawn = await plotModeration3d(panel.plot, data, {\n ...values,\n plotly: engine,\n });\n if (destroyed) {\n return;\n }\n\n engine = drawn.plotly;\n element = drawn.element;\n surface = drawn.surface;\n spec = { traces: drawn.traces, layout: drawn.layout, note: drawn.note };\n note.show(drawn.note);\n\n // One listener for the life of the component: Plotly hands back the same\n // element every time, so attaching per draw would pile them up.\n if (!listening) {\n listening = true;\n element.on(\"plotly_relayout\", handleRelayout);\n }\n\n const moved =\n painted !== null &&\n (painted.zRot !== wanted.zRot || painted.xRot !== wanted.xRot);\n painted = wanted;\n\n const camera = drawn.layout.scene.camera;\n if (moved && camera !== undefined) {\n seenCamera = camera;\n await drawn.plotly.relayout(element, { \"scene.camera\": camera });\n } else if (seenCamera !== undefined && !sameCamera(seenCamera, camera)) {\n // A redraw that asked for no new view: the react above rewrote the\n // stored layout with the sliders' camera while the screen keeps the\n // user's drag (uirevision). Re-persist the drag, or Plotly's own\n // relayouts would rebuild at the sliders' angles after all.\n await drawn.plotly.relayout(element, { \"scene.camera\": seenCamera });\n }\n }\n\n /**\n * Persist a camera the user dragged to into Plotly's stored layout.\n *\n * Plotly's own modebar buttons (orbit, turntable, pan, zoom) relayout the\n * scene from that layout, and a drag lives only in the WebGL scene until it\n * is written back; without this, every modebar click snapped the view to\n * the sliders' angles. The push itself echoes through this handler with the\n * same camera as a fresh object, which is what the value comparison\n * recognizes and drops. The sliders stay in charge: their own pushes set\n * `seenCamera` first, so a slider still overrides any drag before it.\n */\n function handleRelayout(event: PlotlyRelayoutEvent): void {\n const moved = event[\"scene.camera\"];\n if (moved === undefined || destroyed || sameCamera(moved, seenCamera)) {\n return;\n }\n seenCamera = moved;\n if (element !== null && engine !== undefined) {\n // Fire and forget: the picture is already at this view, so a failure\n // here (a plot purged mid-flight) has nothing to repair.\n engine.relayout(element, { \"scene.camera\": moved }).catch(() => undefined);\n }\n }\n\n /**\n * Draw, and never draw twice at once.\n *\n * A dragged slider fires an event for every step, and each draw is\n * asynchronous. A request that arrives while a draw is in flight is\n * remembered, not started, and the draw that follows reads the sliders as\n * they stand then: the last value wins, and the pictures cannot arrive out\n * of order.\n */\n function requestRender(): void {\n if (destroyed) {\n return;\n }\n queued = true;\n inFlight ??= start();\n }\n\n function start(): Promise<void> {\n const run = pump();\n // A caller that never awaits must not be handed an unhandled rejection;\n // `rendered()` still reports the failure to anyone who asks.\n run.catch(() => undefined);\n return run;\n }\n\n async function pump(): Promise<void> {\n try {\n while (queued && !destroyed) {\n queued = false;\n await renderOnce();\n }\n } finally {\n inFlight = null;\n }\n }\n\n function handleInput(event: Event): void {\n const input = event.target as HTMLInputElement;\n // A slider keeps its own value inside the range and on the step, so what\n // it reports needs no correcting.\n values = { ...values, [input.name]: Number(input.value) };\n\n const readout = readouts.get(input.name);\n if (readout !== undefined) {\n readout.textContent = input.value;\n }\n requestRender();\n }\n\n const built: HTMLElement[] = [];\n const inputs: HTMLInputElement[] = [];\n const readouts = new Map<string, HTMLElement>();\n\n for (const slider of SLIDERS) {\n const control = buildSlider(\n owner,\n slider.name,\n slider.label,\n slider.range,\n values[slider.name],\n );\n panel.controls.appendChild(control.wrapper);\n built.push(control.wrapper);\n inputs.push(control.input);\n readouts.set(slider.name, control.readout);\n control.input.addEventListener(\"input\", handleInput);\n }\n\n panel.controls.appendChild(note.element);\n built.push(note.element);\n\n // R's renderPlot runs as the gadget opens, at the initial settings.\n requestRender();\n\n return {\n getValues: () => ({ ...values }),\n getSurface: () => surface,\n getSpec: () => spec,\n rendered: () => inFlight ?? Promise.resolve(),\n done() {\n onDone?.({ ...values });\n },\n destroy() {\n if (destroyed) {\n return;\n }\n destroyed = true;\n for (const input of inputs) {\n input.removeEventListener(\"input\", handleInput);\n }\n for (const node of built) {\n node.remove();\n }\n if (element !== null) {\n element.removeAllListeners(\"plotly_relayout\");\n engine?.purge(element);\n }\n panel.release();\n },\n };\n}\n",
|
|
17
|
-
"/**\n * The `moderation_data` dataset of the R package.\n *\n * Two hundred rows of a moderated relationship, used as the default data of\n * `plot_moderation_3d()` and `plot_scatter3d()` so that both work with no\n * arguments. R's `data.R` records the recipe: `x`, `z` and `w` are drawn\n * independently from a normal distribution with standard deviation 2, and\n *\n * ```text\n * y = 0.5 x + 0.3 z + 0.8 x z + N(0, 1)\n * ```\n *\n * so the effect of `x` on `y` grows with `z` — the interaction the surface\n * shows as a twist. Column `w` enters no equation: it is noise, and it is\n * there so an example can carry a control variable that means nothing.\n *\n * The values below are the exact doubles of the R data file\n * (`../compstatslib/data/moderation_data.rda`), printed at 17 significant\n * digits, which round-trips an IEEE-754 double. **Exported from R, never\n * regenerated** — the draw used `set.seed(42)` under R's own generator, so a\n * JavaScript regeneration would produce different numbers and silently change\n * every default demo. Source of the printed values:\n * `.claude/plans/moderation-data.tsv`, checked against the column checksums of\n * `.claude/plans/moderation-fixtures.md` in `moderationData.test.ts`.\n *\n * The columns are in the order of the R data frame — `y, x, z, w`, not\n * alphabetical and not `x, y, z`. That order is load-bearing: `plot_scatter3d()`\n * with no axis arguments takes the first three numeric columns, which is why\n * its default plot puts `y` on the horizontal axis.\n */\n\n/** The four columns of the R `moderation_data` data frame. */\nexport type ModerationData = {\n readonly y: readonly number[];\n readonly x: readonly number[];\n readonly z: readonly number[];\n readonly w: readonly number[];\n};\n\n/** The 200 rows of the R `moderation_data` data frame, in file order. */\nexport const moderationData: ModerationData = {\n y: [\n -7.2728972000711964, -1.8368504105536234,\n 2.4825030269210964, 6.0885502472158235,\n -2.7813932586215913, -1.4045477434849749,\n -2.3283702256411951, 0.24770227680217238,\n -1.0630104614416778, -2.0458910688111343,\n -5.1341052959159876, 18.102464141094789,\n -3.4663420296290077, -1.0047522093312424,\n -0.82474666408975483, 0.011971257899126564,\n -2.4321918294924254, -14.110628278307653,\n -1.5077118301445713, -3.3519580636316557,\n 0.34228397854096548, -1.4420566151665186,\n -0.09954101599791107, -4.1717572290618348,\n 5.638370200339164, -0.24209932633994577,\n -0.92942202986679767, -0.14306775813444911,\n -0.75191873199673909, -2.6149345603765624,\n 1.9162030995224288, 2.882308922335612,\n -4.1366719661768885, -1.5262757249783787,\n -0.13241561132928859, 1.0868995782488633,\n -5.4322398208224598, -1.0526454319438507,\n -5.3360807036936473, 0.80370589439224283,\n 0.64566701092436662, -0.58086531051744095,\n 5.9958208137315907, -3.748881331929856,\n 4.7991068639205681, 3.9170147432586608,\n -2.5205797162580499, 1.0052100508228277,\n -1.2592451123609627, -1.4191054380364576,\n -2.7688068774363885, -1.1283556266006958,\n -5.0155719117359876, 0.74436508929657408,\n 1.3457889732609731, -1.5775936354323048,\n 0.24940175331052905, 0.84534536563058338,\n 9.1086395504851989, -1.0895764398669741,\n -0.054834750835499602, 3.4396743692990768,\n 1.82777129315956, -9.0876817903961307,\n -1.6403441299936004, 6.3441120121592336,\n 3.0068415808329494, 1.0402916701960967,\n -10.792485667257104, 0.19774249672127087,\n -2.6230964327485333, -1.5340564759379902,\n 1.7265739813235901, -4.4727441322331023,\n 0.051358701883551766, 3.4112581498484817,\n 1.7155585583877218, -2.4096746494084527,\n -3.6580899543881662, -4.2196299413161089,\n 5.7706115536478979, -4.0368554837030199,\n -1.8534915424952012, -1.4551065653571458,\n -0.57333130613680428, 1.2587331393918402,\n -0.18074955316901531, -1.7541060455623132,\n -7.1816739672594787, 2.2681715762809351,\n -2.2618552849857134, -1.0033432551835315,\n -1.5998101004488254, 13.776336779706227,\n -1.3601934670356379, 0.84377053596043516,\n 0.26923062515768637, -6.1587204803542566,\n 0.28455942391067712, -3.7313390977173673,\n 2.209575611277963, 4.9573155152467479,\n -1.1074416328100625, 6.773590899689121,\n -1.1622855609602678, -0.1468882418607233,\n -1.8138297100034615, -0.88229772478568436,\n -2.5310587963205209, 0.92250684930151283,\n 1.0529999297345707, -1.0226841183124429,\n -0.62826191336833026, 0.047095104558446066,\n -2.1862971987559754, 1.9185432668727294,\n -1.4157898788687031, 3.8559400012867275,\n 4.8196910254616006, 1.1859049624611124,\n 2.1292032810255828, -2.5804694939165822,\n 0.7806460650847441, -0.77177474486716457,\n 4.3023231287427057, 1.1280497997890846,\n -3.3823450205179935, -2.8141768087650334,\n 1.9176969652481777, -1.8022438527307034,\n 0.56769922608595746, -1.1988798479187797,\n -0.81127142895301252, 3.0023694027723717,\n 6.3138141892914694, -0.72091317245731745,\n -0.49342129711845351, -5.3116450695380282,\n 1.5864321371634191, -1.3767448543412033,\n -0.32149297043332475, -2.7378068772633672,\n 0.44512957644982276, 1.0144155909083761,\n -0.33982995595512711, 3.6424411700938926,\n -0.80484964968788497, 0.26491344714041165,\n 1.0255159271802998, -3.4431481857611512,\n -1.2617728430815081, 2.4072718264535986,\n 4.1858481441966102, 0.84449896500128463,\n 0.68906644248057036, -4.9301730292087731,\n 1.3181686730513686, -3.9504745741065488,\n 0.69966539975680719, -7.7331713344467277,\n 0.37966613312994063, 2.0980485157760418,\n 0.58696762292169558, -0.095335203753901337,\n -1.3602473690753563, -1.8363341184552933,\n -5.3271971097587407, -2.4667878836756927,\n -0.84771180433706672, 1.794347325600735,\n -1.1215052328640052, 0.96938089278474238,\n -8.8525095689727635, -10.171192748327044,\n 5.5154793606449468, 0.81334743443491231,\n 1.5442257490953633, -2.3028072866769134,\n 0.68983698216899647, 1.9915198521027817,\n 2.8322478461703762, 0.34764862749885805,\n -0.50342712629907482, 1.1733004427545144,\n 0.18449984894824215, -1.9938893833160367,\n 0.8829064829548916, 0.62667972173052222,\n -3.9311936779928676, -4.6930573223273164,\n 0.5942425542793619, -0.040913228103484439,\n 1.5529759191506414, 0.52558975177612277,\n -0.51812524140199456, 5.7138238288601553,\n 0.80645695222572478, 2.7208395005315182,\n -1.9931388422548042, 2.0982441518090775,\n ],\n x: [\n 2.741916894293337, -1.1293963427921776,\n 0.72625682267467828, 1.265725209922081,\n 0.80853664628199817, -0.21224903218296798,\n 3.0230439948778778, -0.18931807682619511,\n 4.0368474277540827, -0.12542819810484199,\n 2.6097393084469704, 4.5732907854022136,\n -2.7777214022246786, -0.55757753363474283,\n -0.26664267278731602, 1.2719007961401489,\n -0.56850584283214478, -5.3129108418095523,\n -4.8809338571510379, 2.6402266914603838,\n -0.6132771881569492, -3.562616867960001,\n -0.34383471151924272, 2.4293493983451979,\n 3.7903869225299305, -0.86093826321239919,\n -0.51453876553785927, -3.5263261703895603,\n 0.9201947096625428, -1.2799897519202386,\n 0.91090024648243872, 1.4096746744576383,\n 2.0702070439398446, -1.2178527508144228,\n 1.0099102465959404, -3.434017358146686,\n -1.5689180167589927, -1.7018151883530368,\n -4.8284152998932646, 0.07224521378451125,\n 0.41199720040050775, -0.72211459709733239,\n 1.5163264713990341, -1.4534096541531503,\n -2.7365620888385891, 0.86563605177743408,\n -1.6227863523733432, 2.8882025234425055,\n -0.86289240522669086, 1.3112957668044132,\n 0.64385053040789308, -1.5676778817607508,\n 3.1514550395839547, 1.2857986114346329,\n 0.17952129319921128, 0.5531014945829259,\n 1.3585776321105416, 0.17966577315816343,\n -5.9861801663058696, 0.5697659070613188,\n -0.73446928548195067, 0.3704611297312187,\n 1.1636474547310138, 2.799473654585356,\n -1.4545841189489299, 2.6050852640882871,\n 0.67169623950414881, 2.0770121973952422,\n 1.8414571365812926, 1.4417563257337251,\n -2.08623787713571, -0.18037277322141337,\n 1.2470363239990871, -1.907046715544688,\n -1.0856576291477136, 1.1619929953633648,\n 1.536357475669182, 0.92753517708033439,\n -1.7715525948193589, -2.1995617972957109,\n 3.025414019609856, 0.51584287506406168,\n 0.17688045831917268, -0.24179307507817885,\n -2.3886577903210564, 1.2239937960807739,\n -0.43427969149304169, -0.36551341266384341,\n 1.8666926571423201, 1.6435462210164979,\n 2.7842327518685419, -0.95234784610934875,\n 1.3006971214526097, 2.7822209127800015,\n -2.2215777588957977, -1.7215851737556847,\n -2.2634773617075399, -2.9184279990047917,\n 0.15996510648232234, 1.30640867929838,\n 2.4019307511969883, 2.0895021743354505,\n -2.006417293679696, 3.696963803345493,\n -1.3335468175156342, 0.21102762491213886,\n -0.84451176373771208, -0.24470034390994258,\n 0.37638606900299576, 0.23832191599401276,\n -0.050185101734805754, 0.2161454558840652,\n -0.9708704716933354, -1.0084342613758068,\n -3.322198159829624, -0.76466745374763623,\n -1.025300515755601, 5.4037820006895947,\n -2.7242324623794376, 0.27451243711721379,\n -2.987250134632581, -2.9408714828735931,\n 0.2494047723940136, -1.9932782697680742,\n -0.0036452286094163897, -0.85651776285163062,\n -1.2273432128989903, -4.0493556908382153,\n -2.4494959007199721, 0.35903288223587582,\n 1.1352411888470701, -0.98575470710694957,\n 0.00012576813070224816, 2.2457792867599329,\n 2.87971148595238, -2.1942275368116433,\n -0.23463912050035363, 2.4029968018394023,\n -0.93945916113260175, -0.10493896987799263,\n -0.17221459647417905, -1.7753580358128629,\n -0.88936800976947616, -0.058889758176476292,\n -0.82773769811584708, 2.2267720467364067,\n -0.96198568330796386, -0.86633806520145806,\n 1.3937251531042052, -2.1127368263418163,\n -0.081396950302429855, -3.1030896446951792,\n 2.3343390984713639, -0.54729140274816135,\n -0.93569064934450719, -2.4765046559724295,\n -0.015524067554653256, -1.6005643559033189,\n -1.066984659900873, 2.5753504911691776,\n -0.35105174048425475, -2.1435647683013519,\n 0.32641376493476459, -0.72547683125589957,\n 1.1800270959746773, 2.8648438554619791,\n -1.9853850222189862, 0.90930059516056516,\n 0.16979611735697459, 1.7911311645290895,\n -0.45955627789253306, 1.6732381369212268,\n -3.4901117226733867, 3.378917842626747,\n 1.7295559570371559, -0.30155197777149562,\n -2.8980142602783352, 1.2860174000839635,\n 0.96638772762953518, -0.012711252842777425,\n 0.30291178572484884, -1.1682179406996087,\n 0.73761346526048421, 0.5893086794390312,\n -0.55851874668515011, -2.6724733097863078,\n 1.4014976368800685, 1.1083932445480671,\n -1.6726131856028299, -3.189176324012486,\n 0.40991716117526766, -0.69017595594577974,\n 0.50522340672890931, -2.5880049309691064,\n -1.9183408887607261, 2.1715497073598016,\n 0.80754980943142785, 1.1729750734385955,\n 3.6304568923079059, 0.25764285720476621,\n ],\n z: [\n -4.0018584754630222, 0.66755439486714041,\n 2.3426502547175891, 4.1190784845986084,\n -2.7537231964810425, -2.3017111312542111,\n -1.4116427895202421, -2.1081115641543828,\n -1.2914874462849828, -0.37075593535300683,\n -2.4024441014799702, 4.0739443339663,\n 0.21554948977109339, -0.16821620101116128,\n 0.99123928320918786, 0.074830372235930684,\n -0.2641760739118198, 2.9535748471041936,\n -0.43406042018420693, -2.5672044081844505,\n 0.77133578088680466, -0.70302574705818488,\n -1.0435921867125384, -2.1362624013743408,\n 0.85673180653338499, -0.34803646885398981,\n 1.0313354572960587, -0.46873055461184299,\n -1.3170068516435418, 2.500473208157433,\n -0.54352743022279359, 1.8959039917503921,\n -2.4031648602178755, -0.93223219275100444,\n -0.53870279030635992, -0.78193081626172145,\n 2.697414023983427, -0.04552940259682519,\n 0.48845170220690071, -1.8847434157278455,\n -1.4584345530191491, 1.9961378171096964,\n 2.5169633291911206, 2.4977273776201918,\n -2.7612740990506603, 4.0999213872727882,\n 2.0337456595990835, -0.053434928276515886,\n 1.4072155575965211, -1.9427704583037273,\n -2.1923124831177145, 0.098100901875194116,\n -2.3969917131155598, 0.38003799711949598,\n 2.5954117992093324, -2.067747445929502,\n -1.4768815084261278, 0.093127878901726704,\n -2.0351922396522117, -0.76656791977255634,\n 1.7455108233427969, 1.9390900279402341,\n 0.76769333005418883, -3.7031113261349291,\n -0.10799347365233136, 2.1295464286765675,\n 1.6263900748232101, -0.38163294820856347,\n -5.3998596171274054, 0.1219332776022331,\n 1.1475033949671558, 0.091607159450197734,\n 0.31482508035175089, 0.86313074573754156,\n -0.79309947210042442, 2.6199564515030986,\n 0.94078679974788604, -2.4853405411492027,\n 2.7631509127710658, 2.4089178740196484,\n 1.648147927363762, -3.3252588043711886,\n -1.1386126872109616, 1.2710276345790525,\n 0.087444015155715843, 0.69602460732261417,\n 4.9191870977408296, -1.6367606487993389,\n -4.2264002298582737, 0.54739054486082928,\n -1.3751936824868236, 0.89208210592373138,\n -1.6247694475811947, 4.424110960670272,\n -0.24741194315485965, -0.95467101206010463,\n -0.33252298297321642, 1.7251267672528618,\n 0.19468097040563787, -3.2512334784225763,\n -0.00924153565291559, 1.5204843353241098,\n 0.077981825745125244, 1.4701442832288814,\n -0.29294525399773952, -0.11577467076256517,\n 0.96473893220906526, 1.9858872735514685,\n -2.4927909960640844, -0.066975049691219368,\n -0.1419243624999926, -1.517841307461901,\n -2.0687187218783056, -1.2614639079416392,\n 1.1736154400259904, -0.83264531236730377,\n -1.5697756190106404, 0.32683263897219417,\n -2.4734284702186993, 2.0917475524733429,\n -0.96919083243741866, 0.37825762336133084,\n 0.10201266314994641, -0.00048133777288395359,\n 3.6187640848857319, -1.6506559142198896,\n 2.2909409044559705, 0.063146375106486144,\n -1.6704116106134392, -0.13752729803302502,\n 1.4935433740249338, -0.85103746878920816,\n -1.5441644703869135, 0.30552821349578935,\n 1.977193690357598, -0.14691666934434808,\n -2.7740531071194838, -2.6133518087507257,\n -1.5367906501558772, -1.0542162507489161,\n -0.042854130083249252, 1.3409961419925638,\n -0.86923407714481304, -2.2277595666256937,\n 1.2142119897569996, 0.5509139374791826,\n 2.3146941388294735, -3.3649617189565113,\n 0.17463817778974872, 2.7067237878853372,\n 1.4483476013667382, -1.665105651528423,\n 1.4650569735368288, -1.7438537399944254,\n -0.90679502245958543, 2.3750685572581554,\n -0.58029062358015848, 1.6570922899308729,\n -0.58245541755833752, -3.1527248094958122,\n -1.6976313938978438, -2.1770397239143895,\n -0.96858114223434699, -0.67262241801914557,\n -0.30671578132328758, -0.48649445714969192,\n 3.784404083200223, -2.7719966745708398,\n -0.82964860141556074, 0.69816305621366226,\n 3.256884531630813, 0.17704379142723264,\n 2.4783014168011261, -3.2891110715074134,\n 2.8927130507569592, -1.3811203433303656,\n -0.55286217090770406, -2.2188375197988743,\n 0.26773863285890354, 3.5706781034631039,\n 4.8443267105031795, -2.1536578042368233,\n 0.97188222080619802, 2.7770434774885837,\n -0.3913136345690878, -0.43634959541242196,\n -0.60955590909289048, 1.1956654482228859,\n 2.7948588216315193, 1.3752395224799268,\n 0.64037602859393727, -0.60373985155452159,\n 0.99669737111589907, -1.0990738358335126,\n -0.55851300727448538, 2.1930268862234645,\n 0.88402617635762248, 0.48203258805222476,\n -0.51121531071103665, 1.8620658029697648,\n ],\n w: [\n -0.49696586637986573, 0.84464077166478657,\n 1.9753065872793472, 1.6711363440700464,\n -1.321043718091411, 3.1281389865836706,\n -3.2459518705830939, 1.7277927469579759,\n -1.0232055468724002, -3.8347300508908027,\n -3.731627697239897, 0.4903581268793773,\n 4.447068603816132, 0.54675212828893049,\n 2.261569589056565, 1.6773387481201982,\n -1.3092305557564106, 1.9079219569587911,\n 0.70590293097864509, 0.41319858529922687,\n 2.0022264686204969, 1.4949039832805529,\n -1.2531496734462773, 0.79044737187342806,\n -1.7843359080911552, 1.2616368201835455,\n -0.86541036656913495, 0.90427728843703359,\n 0.73599809039269093, -0.54077497932381824,\n 0.9310252354259575, 1.1487124512539382,\n -0.46139998031482182, 2.3444850166049025,\n 2.7854054134662434, -1.3239825114191694,\n -1.5547384134500284, 1.0270771578175601,\n -1.8266244760825443, -0.89884761050060125,\n 1.6058653982072366, -1.1469537019622078,\n -3.8562503356966524, 1.3287816676442965,\n -3.205080447588506, -2.7092005149076992,\n -6.0358653588357924, 1.6624756444601259,\n 0.50219417769468799, 0.92458693188265906,\n 1.6895844464464735, -0.083943048643124199,\n -2.2111518114000552, 1.1275513046617478,\n 2.6067295116393412, -3.0004418755893147,\n -1.2139784702380723, -0.58449013131315453,\n -2.579366686647206, 1.3882116975493977,\n -1.1983638057942381, 2.5138132879432744,\n 0.10701602725472605, 1.4561850353437049,\n 3.1221961364212145, 0.53124950719437969,\n 2.1534525184145346, 0.42139586335849089,\n -3.0233470516447363, 0.044804519827250026,\n 1.4362724120842063, 0.97891403568453961,\n -0.34777669175653925, -2.435398977336801,\n 1.292796737418924, -1.8329120566957797,\n -2.5036468848511326, 1.1898554368110026,\n -2.465621330379653, 0.48872882981227517,\n 0.005544370687190118, -2.65641937205113,\n 2.3593928236655501, -1.1856099982978574,\n 2.3999566326733439, -0.95006735922426966,\n -1.1501141923016327, -0.062452049216998061,\n -0.71611399195691117, -0.7132021552954626,\n -1.7553287668674522, -2.4257942503559256,\n 1.2265732373740676, -1.6124066829249548,\n -2.7529138598177902, -1.0156957983270942,\n -1.6018709734746754, -4.3855713713401352,\n -0.58187429853534967, 0.33434824232103538,\n 0.5893847129713754, 0.7854825308414517,\n -2.0016874260016304, -0.65145423964686777,\n -2.0166976108576851, -1.2708629640675322,\n -2.4196813759746849, -2.2329276013053807,\n 1.2597623251518704, -0.54504314035725121,\n -0.5176823367573421, 3.4591163597829868,\n -0.11678433081474329, -1.0741275692178371,\n 1.4945733923314797, -0.97451567077946588,\n 2.7458155629590104, -0.75534472129244146,\n -1.2323052282367883, -2.3362501021493713,\n 0.65728071718217163, 2.9330212548803298,\n -0.71201909017782516, 0.5229352837548622,\n 0.66665771035146226, 2.8443864806190855,\n 1.3277532013323454, -2.1473103113906209,\n -1.3938035493334802, -1.4922609138691223,\n 0.28314574426443873, -0.0078944414613061446,\n 0.73587500218353108, -1.3146858293944941,\n -0.75269334032210411, 1.4827201208501692,\n -0.19921351289694036, -1.3085797572141897,\n 1.942328748122542, 0.02699262313677293,\n -1.8330693340430899, 3.4193771225232736,\n -2.3362019798933114, -3.5620725203050472,\n -4.5062648971364343, 1.3022519390933986,\n -1.0656652512055347, -0.55111871394456635,\n 0.57925394525809126, -0.93296812358152814,\n -3.2161203498893749, -3.8995675920839759,\n -0.68139983646196156, 0.3494510546626397,\n -4.5555551215544581, 0.58104896189416777,\n 0.84461271494722856, 2.5894747264134295,\n 0.32942803714790875, 0.40990768160047042,\n 1.2092072534516118, -0.038281538337862839,\n -0.15942869475761728, 0.2319689288056091,\n 1.4883467280967757, -0.86258120705538532,\n -0.99905790382246884, -1.7303241535114227,\n -1.915514566543747, 0.65359994267727539,\n 3.0947444513703499, -1.9377191377288612,\n -0.37688085251892567, -2.0600023229118372,\n 1.8161728837209921, -0.63476372941625703,\n 0.35800793308084394, 0.6960563754583543,\n -2.1085580425488804, -0.20948857622140291,\n -0.45668523418905876, 1.3507111248550778,\n -2.4664893870126186, -2.3999230888455583,\n 1.5317331532322156, -1.1761957225659538,\n -1.3205916599511518, 0.22602704439468746,\n -0.64079759937207748, 3.7327629938775755,\n 0.51906291153559747, 0.32312014183613985,\n 1.8621498186707084, -0.11989349851924225,\n 0.097479400154900323, -2.1457508014679263,\n -4.5859428609613451, -2.4144137001286841,\n 0.22821885959438232, -2.0665941582107541,\n ],\n};\n"
|
|
24
|
+
"/**\n * The `moderation_data` dataset of the R package.\n *\n * Two hundred rows of a moderated relationship, used as the default data of\n * `plot_moderation_3d()` and `plot_scatter3d()` so that both work with no\n * arguments. R's `data.R` records the recipe: `x`, `z` and `w` are drawn\n * independently from a normal distribution with standard deviation 2, and\n *\n * ```text\n * y = 0.5 x + 0.3 z + 0.8 x z + N(0, 1)\n * ```\n *\n * so the effect of `x` on `y` grows with `z` — the interaction the surface\n * shows as a twist. Column `w` enters no equation: it is noise, and it is\n * there so an example can carry a control variable that means nothing.\n *\n * The values below are the exact doubles of the R data file\n * (`../compstatslib/data/moderation_data.rda`), printed at 17 significant\n * digits, which round-trips an IEEE-754 double. **Exported from R, never\n * regenerated** — the draw used `set.seed(42)` under R's own generator, so a\n * JavaScript regeneration would produce different numbers and silently change\n * every default demo. Source of the printed values:\n * `.claude/plans/001-PLAN-port/moderation-data.tsv`, checked against the column checksums of\n * `.claude/plans/001-PLAN-port/moderation-fixtures.md` in `moderationData.test.ts`.\n *\n * The columns are in the order of the R data frame — `y, x, z, w`, not\n * alphabetical and not `x, y, z`. That order is load-bearing: `plot_scatter3d()`\n * with no axis arguments takes the first three numeric columns, which is why\n * its default plot puts `y` on the horizontal axis.\n */\n\n/** The four columns of the R `moderation_data` data frame. */\nexport type ModerationData = {\n readonly y: readonly number[];\n readonly x: readonly number[];\n readonly z: readonly number[];\n readonly w: readonly number[];\n};\n\n/** The 200 rows of the R `moderation_data` data frame, in file order. */\nexport const moderationData: ModerationData = {\n y: [\n -7.2728972000711964, -1.8368504105536234,\n 2.4825030269210964, 6.0885502472158235,\n -2.7813932586215913, -1.4045477434849749,\n -2.3283702256411951, 0.24770227680217238,\n -1.0630104614416778, -2.0458910688111343,\n -5.1341052959159876, 18.102464141094789,\n -3.4663420296290077, -1.0047522093312424,\n -0.82474666408975483, 0.011971257899126564,\n -2.4321918294924254, -14.110628278307653,\n -1.5077118301445713, -3.3519580636316557,\n 0.34228397854096548, -1.4420566151665186,\n -0.09954101599791107, -4.1717572290618348,\n 5.638370200339164, -0.24209932633994577,\n -0.92942202986679767, -0.14306775813444911,\n -0.75191873199673909, -2.6149345603765624,\n 1.9162030995224288, 2.882308922335612,\n -4.1366719661768885, -1.5262757249783787,\n -0.13241561132928859, 1.0868995782488633,\n -5.4322398208224598, -1.0526454319438507,\n -5.3360807036936473, 0.80370589439224283,\n 0.64566701092436662, -0.58086531051744095,\n 5.9958208137315907, -3.748881331929856,\n 4.7991068639205681, 3.9170147432586608,\n -2.5205797162580499, 1.0052100508228277,\n -1.2592451123609627, -1.4191054380364576,\n -2.7688068774363885, -1.1283556266006958,\n -5.0155719117359876, 0.74436508929657408,\n 1.3457889732609731, -1.5775936354323048,\n 0.24940175331052905, 0.84534536563058338,\n 9.1086395504851989, -1.0895764398669741,\n -0.054834750835499602, 3.4396743692990768,\n 1.82777129315956, -9.0876817903961307,\n -1.6403441299936004, 6.3441120121592336,\n 3.0068415808329494, 1.0402916701960967,\n -10.792485667257104, 0.19774249672127087,\n -2.6230964327485333, -1.5340564759379902,\n 1.7265739813235901, -4.4727441322331023,\n 0.051358701883551766, 3.4112581498484817,\n 1.7155585583877218, -2.4096746494084527,\n -3.6580899543881662, -4.2196299413161089,\n 5.7706115536478979, -4.0368554837030199,\n -1.8534915424952012, -1.4551065653571458,\n -0.57333130613680428, 1.2587331393918402,\n -0.18074955316901531, -1.7541060455623132,\n -7.1816739672594787, 2.2681715762809351,\n -2.2618552849857134, -1.0033432551835315,\n -1.5998101004488254, 13.776336779706227,\n -1.3601934670356379, 0.84377053596043516,\n 0.26923062515768637, -6.1587204803542566,\n 0.28455942391067712, -3.7313390977173673,\n 2.209575611277963, 4.9573155152467479,\n -1.1074416328100625, 6.773590899689121,\n -1.1622855609602678, -0.1468882418607233,\n -1.8138297100034615, -0.88229772478568436,\n -2.5310587963205209, 0.92250684930151283,\n 1.0529999297345707, -1.0226841183124429,\n -0.62826191336833026, 0.047095104558446066,\n -2.1862971987559754, 1.9185432668727294,\n -1.4157898788687031, 3.8559400012867275,\n 4.8196910254616006, 1.1859049624611124,\n 2.1292032810255828, -2.5804694939165822,\n 0.7806460650847441, -0.77177474486716457,\n 4.3023231287427057, 1.1280497997890846,\n -3.3823450205179935, -2.8141768087650334,\n 1.9176969652481777, -1.8022438527307034,\n 0.56769922608595746, -1.1988798479187797,\n -0.81127142895301252, 3.0023694027723717,\n 6.3138141892914694, -0.72091317245731745,\n -0.49342129711845351, -5.3116450695380282,\n 1.5864321371634191, -1.3767448543412033,\n -0.32149297043332475, -2.7378068772633672,\n 0.44512957644982276, 1.0144155909083761,\n -0.33982995595512711, 3.6424411700938926,\n -0.80484964968788497, 0.26491344714041165,\n 1.0255159271802998, -3.4431481857611512,\n -1.2617728430815081, 2.4072718264535986,\n 4.1858481441966102, 0.84449896500128463,\n 0.68906644248057036, -4.9301730292087731,\n 1.3181686730513686, -3.9504745741065488,\n 0.69966539975680719, -7.7331713344467277,\n 0.37966613312994063, 2.0980485157760418,\n 0.58696762292169558, -0.095335203753901337,\n -1.3602473690753563, -1.8363341184552933,\n -5.3271971097587407, -2.4667878836756927,\n -0.84771180433706672, 1.794347325600735,\n -1.1215052328640052, 0.96938089278474238,\n -8.8525095689727635, -10.171192748327044,\n 5.5154793606449468, 0.81334743443491231,\n 1.5442257490953633, -2.3028072866769134,\n 0.68983698216899647, 1.9915198521027817,\n 2.8322478461703762, 0.34764862749885805,\n -0.50342712629907482, 1.1733004427545144,\n 0.18449984894824215, -1.9938893833160367,\n 0.8829064829548916, 0.62667972173052222,\n -3.9311936779928676, -4.6930573223273164,\n 0.5942425542793619, -0.040913228103484439,\n 1.5529759191506414, 0.52558975177612277,\n -0.51812524140199456, 5.7138238288601553,\n 0.80645695222572478, 2.7208395005315182,\n -1.9931388422548042, 2.0982441518090775,\n ],\n x: [\n 2.741916894293337, -1.1293963427921776,\n 0.72625682267467828, 1.265725209922081,\n 0.80853664628199817, -0.21224903218296798,\n 3.0230439948778778, -0.18931807682619511,\n 4.0368474277540827, -0.12542819810484199,\n 2.6097393084469704, 4.5732907854022136,\n -2.7777214022246786, -0.55757753363474283,\n -0.26664267278731602, 1.2719007961401489,\n -0.56850584283214478, -5.3129108418095523,\n -4.8809338571510379, 2.6402266914603838,\n -0.6132771881569492, -3.562616867960001,\n -0.34383471151924272, 2.4293493983451979,\n 3.7903869225299305, -0.86093826321239919,\n -0.51453876553785927, -3.5263261703895603,\n 0.9201947096625428, -1.2799897519202386,\n 0.91090024648243872, 1.4096746744576383,\n 2.0702070439398446, -1.2178527508144228,\n 1.0099102465959404, -3.434017358146686,\n -1.5689180167589927, -1.7018151883530368,\n -4.8284152998932646, 0.07224521378451125,\n 0.41199720040050775, -0.72211459709733239,\n 1.5163264713990341, -1.4534096541531503,\n -2.7365620888385891, 0.86563605177743408,\n -1.6227863523733432, 2.8882025234425055,\n -0.86289240522669086, 1.3112957668044132,\n 0.64385053040789308, -1.5676778817607508,\n 3.1514550395839547, 1.2857986114346329,\n 0.17952129319921128, 0.5531014945829259,\n 1.3585776321105416, 0.17966577315816343,\n -5.9861801663058696, 0.5697659070613188,\n -0.73446928548195067, 0.3704611297312187,\n 1.1636474547310138, 2.799473654585356,\n -1.4545841189489299, 2.6050852640882871,\n 0.67169623950414881, 2.0770121973952422,\n 1.8414571365812926, 1.4417563257337251,\n -2.08623787713571, -0.18037277322141337,\n 1.2470363239990871, -1.907046715544688,\n -1.0856576291477136, 1.1619929953633648,\n 1.536357475669182, 0.92753517708033439,\n -1.7715525948193589, -2.1995617972957109,\n 3.025414019609856, 0.51584287506406168,\n 0.17688045831917268, -0.24179307507817885,\n -2.3886577903210564, 1.2239937960807739,\n -0.43427969149304169, -0.36551341266384341,\n 1.8666926571423201, 1.6435462210164979,\n 2.7842327518685419, -0.95234784610934875,\n 1.3006971214526097, 2.7822209127800015,\n -2.2215777588957977, -1.7215851737556847,\n -2.2634773617075399, -2.9184279990047917,\n 0.15996510648232234, 1.30640867929838,\n 2.4019307511969883, 2.0895021743354505,\n -2.006417293679696, 3.696963803345493,\n -1.3335468175156342, 0.21102762491213886,\n -0.84451176373771208, -0.24470034390994258,\n 0.37638606900299576, 0.23832191599401276,\n -0.050185101734805754, 0.2161454558840652,\n -0.9708704716933354, -1.0084342613758068,\n -3.322198159829624, -0.76466745374763623,\n -1.025300515755601, 5.4037820006895947,\n -2.7242324623794376, 0.27451243711721379,\n -2.987250134632581, -2.9408714828735931,\n 0.2494047723940136, -1.9932782697680742,\n -0.0036452286094163897, -0.85651776285163062,\n -1.2273432128989903, -4.0493556908382153,\n -2.4494959007199721, 0.35903288223587582,\n 1.1352411888470701, -0.98575470710694957,\n 0.00012576813070224816, 2.2457792867599329,\n 2.87971148595238, -2.1942275368116433,\n -0.23463912050035363, 2.4029968018394023,\n -0.93945916113260175, -0.10493896987799263,\n -0.17221459647417905, -1.7753580358128629,\n -0.88936800976947616, -0.058889758176476292,\n -0.82773769811584708, 2.2267720467364067,\n -0.96198568330796386, -0.86633806520145806,\n 1.3937251531042052, -2.1127368263418163,\n -0.081396950302429855, -3.1030896446951792,\n 2.3343390984713639, -0.54729140274816135,\n -0.93569064934450719, -2.4765046559724295,\n -0.015524067554653256, -1.6005643559033189,\n -1.066984659900873, 2.5753504911691776,\n -0.35105174048425475, -2.1435647683013519,\n 0.32641376493476459, -0.72547683125589957,\n 1.1800270959746773, 2.8648438554619791,\n -1.9853850222189862, 0.90930059516056516,\n 0.16979611735697459, 1.7911311645290895,\n -0.45955627789253306, 1.6732381369212268,\n -3.4901117226733867, 3.378917842626747,\n 1.7295559570371559, -0.30155197777149562,\n -2.8980142602783352, 1.2860174000839635,\n 0.96638772762953518, -0.012711252842777425,\n 0.30291178572484884, -1.1682179406996087,\n 0.73761346526048421, 0.5893086794390312,\n -0.55851874668515011, -2.6724733097863078,\n 1.4014976368800685, 1.1083932445480671,\n -1.6726131856028299, -3.189176324012486,\n 0.40991716117526766, -0.69017595594577974,\n 0.50522340672890931, -2.5880049309691064,\n -1.9183408887607261, 2.1715497073598016,\n 0.80754980943142785, 1.1729750734385955,\n 3.6304568923079059, 0.25764285720476621,\n ],\n z: [\n -4.0018584754630222, 0.66755439486714041,\n 2.3426502547175891, 4.1190784845986084,\n -2.7537231964810425, -2.3017111312542111,\n -1.4116427895202421, -2.1081115641543828,\n -1.2914874462849828, -0.37075593535300683,\n -2.4024441014799702, 4.0739443339663,\n 0.21554948977109339, -0.16821620101116128,\n 0.99123928320918786, 0.074830372235930684,\n -0.2641760739118198, 2.9535748471041936,\n -0.43406042018420693, -2.5672044081844505,\n 0.77133578088680466, -0.70302574705818488,\n -1.0435921867125384, -2.1362624013743408,\n 0.85673180653338499, -0.34803646885398981,\n 1.0313354572960587, -0.46873055461184299,\n -1.3170068516435418, 2.500473208157433,\n -0.54352743022279359, 1.8959039917503921,\n -2.4031648602178755, -0.93223219275100444,\n -0.53870279030635992, -0.78193081626172145,\n 2.697414023983427, -0.04552940259682519,\n 0.48845170220690071, -1.8847434157278455,\n -1.4584345530191491, 1.9961378171096964,\n 2.5169633291911206, 2.4977273776201918,\n -2.7612740990506603, 4.0999213872727882,\n 2.0337456595990835, -0.053434928276515886,\n 1.4072155575965211, -1.9427704583037273,\n -2.1923124831177145, 0.098100901875194116,\n -2.3969917131155598, 0.38003799711949598,\n 2.5954117992093324, -2.067747445929502,\n -1.4768815084261278, 0.093127878901726704,\n -2.0351922396522117, -0.76656791977255634,\n 1.7455108233427969, 1.9390900279402341,\n 0.76769333005418883, -3.7031113261349291,\n -0.10799347365233136, 2.1295464286765675,\n 1.6263900748232101, -0.38163294820856347,\n -5.3998596171274054, 0.1219332776022331,\n 1.1475033949671558, 0.091607159450197734,\n 0.31482508035175089, 0.86313074573754156,\n -0.79309947210042442, 2.6199564515030986,\n 0.94078679974788604, -2.4853405411492027,\n 2.7631509127710658, 2.4089178740196484,\n 1.648147927363762, -3.3252588043711886,\n -1.1386126872109616, 1.2710276345790525,\n 0.087444015155715843, 0.69602460732261417,\n 4.9191870977408296, -1.6367606487993389,\n -4.2264002298582737, 0.54739054486082928,\n -1.3751936824868236, 0.89208210592373138,\n -1.6247694475811947, 4.424110960670272,\n -0.24741194315485965, -0.95467101206010463,\n -0.33252298297321642, 1.7251267672528618,\n 0.19468097040563787, -3.2512334784225763,\n -0.00924153565291559, 1.5204843353241098,\n 0.077981825745125244, 1.4701442832288814,\n -0.29294525399773952, -0.11577467076256517,\n 0.96473893220906526, 1.9858872735514685,\n -2.4927909960640844, -0.066975049691219368,\n -0.1419243624999926, -1.517841307461901,\n -2.0687187218783056, -1.2614639079416392,\n 1.1736154400259904, -0.83264531236730377,\n -1.5697756190106404, 0.32683263897219417,\n -2.4734284702186993, 2.0917475524733429,\n -0.96919083243741866, 0.37825762336133084,\n 0.10201266314994641, -0.00048133777288395359,\n 3.6187640848857319, -1.6506559142198896,\n 2.2909409044559705, 0.063146375106486144,\n -1.6704116106134392, -0.13752729803302502,\n 1.4935433740249338, -0.85103746878920816,\n -1.5441644703869135, 0.30552821349578935,\n 1.977193690357598, -0.14691666934434808,\n -2.7740531071194838, -2.6133518087507257,\n -1.5367906501558772, -1.0542162507489161,\n -0.042854130083249252, 1.3409961419925638,\n -0.86923407714481304, -2.2277595666256937,\n 1.2142119897569996, 0.5509139374791826,\n 2.3146941388294735, -3.3649617189565113,\n 0.17463817778974872, 2.7067237878853372,\n 1.4483476013667382, -1.665105651528423,\n 1.4650569735368288, -1.7438537399944254,\n -0.90679502245958543, 2.3750685572581554,\n -0.58029062358015848, 1.6570922899308729,\n -0.58245541755833752, -3.1527248094958122,\n -1.6976313938978438, -2.1770397239143895,\n -0.96858114223434699, -0.67262241801914557,\n -0.30671578132328758, -0.48649445714969192,\n 3.784404083200223, -2.7719966745708398,\n -0.82964860141556074, 0.69816305621366226,\n 3.256884531630813, 0.17704379142723264,\n 2.4783014168011261, -3.2891110715074134,\n 2.8927130507569592, -1.3811203433303656,\n -0.55286217090770406, -2.2188375197988743,\n 0.26773863285890354, 3.5706781034631039,\n 4.8443267105031795, -2.1536578042368233,\n 0.97188222080619802, 2.7770434774885837,\n -0.3913136345690878, -0.43634959541242196,\n -0.60955590909289048, 1.1956654482228859,\n 2.7948588216315193, 1.3752395224799268,\n 0.64037602859393727, -0.60373985155452159,\n 0.99669737111589907, -1.0990738358335126,\n -0.55851300727448538, 2.1930268862234645,\n 0.88402617635762248, 0.48203258805222476,\n -0.51121531071103665, 1.8620658029697648,\n ],\n w: [\n -0.49696586637986573, 0.84464077166478657,\n 1.9753065872793472, 1.6711363440700464,\n -1.321043718091411, 3.1281389865836706,\n -3.2459518705830939, 1.7277927469579759,\n -1.0232055468724002, -3.8347300508908027,\n -3.731627697239897, 0.4903581268793773,\n 4.447068603816132, 0.54675212828893049,\n 2.261569589056565, 1.6773387481201982,\n -1.3092305557564106, 1.9079219569587911,\n 0.70590293097864509, 0.41319858529922687,\n 2.0022264686204969, 1.4949039832805529,\n -1.2531496734462773, 0.79044737187342806,\n -1.7843359080911552, 1.2616368201835455,\n -0.86541036656913495, 0.90427728843703359,\n 0.73599809039269093, -0.54077497932381824,\n 0.9310252354259575, 1.1487124512539382,\n -0.46139998031482182, 2.3444850166049025,\n 2.7854054134662434, -1.3239825114191694,\n -1.5547384134500284, 1.0270771578175601,\n -1.8266244760825443, -0.89884761050060125,\n 1.6058653982072366, -1.1469537019622078,\n -3.8562503356966524, 1.3287816676442965,\n -3.205080447588506, -2.7092005149076992,\n -6.0358653588357924, 1.6624756444601259,\n 0.50219417769468799, 0.92458693188265906,\n 1.6895844464464735, -0.083943048643124199,\n -2.2111518114000552, 1.1275513046617478,\n 2.6067295116393412, -3.0004418755893147,\n -1.2139784702380723, -0.58449013131315453,\n -2.579366686647206, 1.3882116975493977,\n -1.1983638057942381, 2.5138132879432744,\n 0.10701602725472605, 1.4561850353437049,\n 3.1221961364212145, 0.53124950719437969,\n 2.1534525184145346, 0.42139586335849089,\n -3.0233470516447363, 0.044804519827250026,\n 1.4362724120842063, 0.97891403568453961,\n -0.34777669175653925, -2.435398977336801,\n 1.292796737418924, -1.8329120566957797,\n -2.5036468848511326, 1.1898554368110026,\n -2.465621330379653, 0.48872882981227517,\n 0.005544370687190118, -2.65641937205113,\n 2.3593928236655501, -1.1856099982978574,\n 2.3999566326733439, -0.95006735922426966,\n -1.1501141923016327, -0.062452049216998061,\n -0.71611399195691117, -0.7132021552954626,\n -1.7553287668674522, -2.4257942503559256,\n 1.2265732373740676, -1.6124066829249548,\n -2.7529138598177902, -1.0156957983270942,\n -1.6018709734746754, -4.3855713713401352,\n -0.58187429853534967, 0.33434824232103538,\n 0.5893847129713754, 0.7854825308414517,\n -2.0016874260016304, -0.65145423964686777,\n -2.0166976108576851, -1.2708629640675322,\n -2.4196813759746849, -2.2329276013053807,\n 1.2597623251518704, -0.54504314035725121,\n -0.5176823367573421, 3.4591163597829868,\n -0.11678433081474329, -1.0741275692178371,\n 1.4945733923314797, -0.97451567077946588,\n 2.7458155629590104, -0.75534472129244146,\n -1.2323052282367883, -2.3362501021493713,\n 0.65728071718217163, 2.9330212548803298,\n -0.71201909017782516, 0.5229352837548622,\n 0.66665771035146226, 2.8443864806190855,\n 1.3277532013323454, -2.1473103113906209,\n -1.3938035493334802, -1.4922609138691223,\n 0.28314574426443873, -0.0078944414613061446,\n 0.73587500218353108, -1.3146858293944941,\n -0.75269334032210411, 1.4827201208501692,\n -0.19921351289694036, -1.3085797572141897,\n 1.942328748122542, 0.02699262313677293,\n -1.8330693340430899, 3.4193771225232736,\n -2.3362019798933114, -3.5620725203050472,\n -4.5062648971364343, 1.3022519390933986,\n -1.0656652512055347, -0.55111871394456635,\n 0.57925394525809126, -0.93296812358152814,\n -3.2161203498893749, -3.8995675920839759,\n -0.68139983646196156, 0.3494510546626397,\n -4.5555551215544581, 0.58104896189416777,\n 0.84461271494722856, 2.5894747264134295,\n 0.32942803714790875, 0.40990768160047042,\n 1.2092072534516118, -0.038281538337862839,\n -0.15942869475761728, 0.2319689288056091,\n 1.4883467280967757, -0.86258120705538532,\n -0.99905790382246884, -1.7303241535114227,\n -1.915514566543747, 0.65359994267727539,\n 3.0947444513703499, -1.9377191377288612,\n -0.37688085251892567, -2.0600023229118372,\n 1.8161728837209921, -0.63476372941625703,\n 0.35800793308084394, 0.6960563754583543,\n -2.1085580425488804, -0.20948857622140291,\n -0.45668523418905876, 1.3507111248550778,\n -2.4664893870126186, -2.3999230888455583,\n 1.5317331532322156, -1.1761957225659538,\n -1.3205916599511518, 0.22602704439468746,\n -0.64079759937207748, 3.7327629938775755,\n 0.51906291153559747, 0.32312014183613985,\n 1.8621498186707084, -0.11989349851924225,\n 0.097479400154900323, -2.1457508014679263,\n -4.5859428609613451, -2.4144137001286841,\n 0.22821885959438232, -2.0665941582107541,\n ],\n};\n"
|
|
18
25
|
],
|
|
19
|
-
"mappings": ";;;;;;;;;AA+NO,SAAS,UAAU,CACxB,GACA,GACS;AAAA,EACT,IAAI,MAAM,aAAa,MAAM,WAAW;AAAA,IACtC,OAAO,MAAM;AAAA,EACf;AAAA,EACA,OACE,WAAW,EAAE,KAAK,EAAE,GAAG,KACvB,WAAW,EAAE,QAAQ,EAAE,MAAM,KAC7B,WAAW,EAAE,IAAI,EAAE,EAAE;AAAA;AAKzB,SAAS,UAAU,CAAC,GAAwB,GAAiC;AAAA,EAC3E,IAAI,MAAM,aAAa,MAAM,WAAW;AAAA,IACtC,OAAO,MAAM;AAAA,EACf;AAAA,EACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;AAAA;AAIjD,IAAI;AAUG,SAAS,UAAU,GAAwB;AAAA,EAChD,YAAmB,6BAAsB,KAAK,CAAC,WAAW;AAAA,IACxD,MAAM,SAAU,OAA0C,WAAW;AAAA,IACrE,OAAO;AAAA,GACR;AAAA,EACD,OAAO;AAAA;;ACnNF,SAAS,eAAe,CAAC,QAA6C;AAAA,EAC3E,OAAO,OAAO,SAAS,KAAK,OAAO,MAAM,CAAC,UAAU,OAAO,UAAU,QAAQ;AAAA;AAYxE,SAAS,cAAc,CAAC,MAA2B;AAAA,EACxD,OAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,SAC/B,gBAAgB,KAAK,KAAe,CACtC;AAAA;AAcK,SAAS,0BAA0B,CACxC,SACA,QACM;AAAA,EACN,IAAI,QAAQ,SAAS,GAAG;AAAA,IACtB,MAAM,IAAI,WACR,GAAG,kDAAkD,QAAQ,aAC3D,iDACJ;AAAA,EACF;AAAA;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