跳转到主要内容

simpleLinearRegression

引入版本:v20.1.0 执行简单的 (一维) 线性回归。 语法
simpleLinearRegression(x, y)
参数
  • x — 包含自变量值的列。Float64
  • y — 包含因变量值的列。Float64
返回值 返回拟合直线 y = k*x + b 的常数 (k, b)Tuple(Float64, Float64) 示例 完美线性拟合
Query
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]);
Response
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐
│ (1,0)                                                             │
└───────────────────────────────────────────────────────────────────┘
带偏移量的线性拟合
Query
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]);
Response
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐
│ (1,3)                                                             │
└───────────────────────────────────────────────────────────────────┘
最后修改于 2026年6月10日