curvefit_least_squares 函数
对数据做最小二乘多项式拟合;默认次数为 1。
语法
CurveFitting:-LeastSquares([[x1, y1], ...], x)CurveFitting:-LeastSquares(data, x, degree = n)curvefit_least_squares(data, x)
参数与选项
data | 点对 [[x1, y1], ...],或分开的 x、y 列表。 |
|---|---|
var | 变量名称。 |
degree | 可选多项式次数;必须小于数据点个数。 |
示例
- 线性最小二乘
CurveFitting:-LeastSquares([[0, 1], [1, 3], [2, 5]], x)返回 2*x + 1。