Regresión lineal simple
stats-regressionCalcula el ajuste por mínimos cuadrados y = pendiente·x + intercepto, con R² y predicciones. Cuándo: un resultado numérico tiene que ser exacto o reproducible y no estimado. No para: medir cómo se mueven juntas dos series de igual longitud (stats-correlation). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.
EN: Least-squares fit y = slope·x + intercept with R², standard error, and optional predictions for new x values. When: a numeric result has to be exact or reproducible instead of estimated. Not for: measuring how two equal-length series move together (stats-correlation). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X values (array of number; required; at least 2 items). | |
| y | Yes | Y values (array of number; required; at least 2 items). | |
| predict | No | X values to predict (array of number; optional; default []; up to 1000 items). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slope | No | ||
| intercept | No | ||
| r_squared | No | ||
| predictions | No | ||
| standard_error | No |