Types
# LoessOptions interface
packages/stats/src/smoothing/types.ts:47interface LoessOptions {
/**
* Fraction of the sample in each local neighbourhood, in `(0, 1]`.
*
* Smaller follows the data more closely and picks up more turning points;
* larger produces a smoother curve. `highcharts-regression` exposes the same
* control as `loessSmooth`, expressed as a percentage.
*
* @default 0.25
*/
bandwidth: number;
/** Decimal places for the smoothed values. @default 2 */
precision: number;
/**
* Minimum change in Y for a direction reversal to count as a turning point,
* as a fraction of the smoothed Y range. Suppresses noise-level wobble.
*
* @default 0.01
*/
turningPointThreshold: number;
}# SmoothError interface
packages/stats/src/smoothing/types.ts:38interface SmoothError {
ok: false;
method?: "loess";
errorType: RegressionErrorType;
message: string;
}# SmoothSuccess interface
packages/stats/src/smoothing/types.ts:21interface SmoothSuccess {
ok: true;
method: "loess";
/** Smoothed `[x, y]` at each observed x, in ascending x order. */
points: PredictedPoint[];
/** Fraction of the sample used in each local neighbourhood. */
bandwidth: number;
/** Proportion of variance the smoothed curve accounts for. */
r2: number;
rmse: number;
n: number;
/** Direction changes in the smoothed curve, in ascending x order. */
turningPoints: TurningPoint[];
/** Overall direction from the first smoothed value to the last. */
netDirection: "rising" | "falling" | "flat";
}The result of a scatterplot smoother.
Deliberately not a RegressionSuccess. A smoother fits no global model, so
there is no slope, intercept or equation to report, and no predict — a
LOESS value at an unobserved x requires refitting against the whole dataset,
so the curve cannot be projected beyond the data it was built from.
What it can state, and a parametric fit cannot, is shape: where the curve turns, and which way it runs overall.
# TurningPoint interface
packages/stats/src/smoothing/types.ts:4interface TurningPoint {
x: number;
y: number;
kind: "peak" | "trough";
}A point where the smoothed curve changes direction.
# SmoothResult type
packages/stats/src/smoothing/types.ts:45type SmoothResult = SmoothSuccess | SmoothError;