series_fit_line_dynamic()series_fit_line_dynamic()

对序列应用线性回归,返回动态对象。Applies linear regression on a series, returning dynamic object.

采用包含动态数值数组作为输入的表达式,并执行线性回归以找出拟合度最好的那条线。Takes an expression containing dynamic numerical array as input, and does linear regression to find the line that best fits it. 应对时间序列数组使用此函数,拟合 make-series 运算符的输出。This function should be used on time series arrays, fitting the output of make-series operator. 它生成具有以下内容的动态值:It generates a dynamic value with the following content:

  • rsquare:r-square 是用于衡量拟合质量的标准。rsquare: r-square is a standard measure of the fit quality. 它是 [0-1] 范围内的数字,其中 1 表示拟合度最好,0 表示数据无序,与任何直线均不拟合It's a number in the range [0-1], where 1 is the best possible fit, and 0 means the data is unordered and doesn't fit any line
  • slope:近似直线的斜率(即 y=ax+b 中的 a 值)slope: Slope of the approximated line (the a -value from y=ax+b )
  • variance:输入数据的方差variance: Variance of the input data
  • rvariance:剩余方差,即输入数据值和近似数据值之间的方差。rvariance: Residual variance that is the variance between the input data values and the approximated ones.
  • interception:近似直线的截距(即 y=ax+b 中的 b 值)interception: Interception of the approximated line (the b -value from y=ax+b )
  • line_fit:数值数组,其中包含拟合度最好的直线的一系列值。line_fit: Numerical array containing a series of values of the best fit line. 序列长度等于输入数组的长度。The series length is equal to the length of the input array. 它主要用于绘制图表。It's used mainly for charting.

此运算符与 series_fit_line 相似,但与 series-fit-line 不同(它返回动态包)。This operator is similar to series_fit_line, but unlike series-fit-line it returns a dynamic bag.

语法Syntax

series_fit_line_dynamic(x)series_fit_line_dynamic(x)

参数Arguments

  • x:数值的动态数组。x : Dynamic array of numeric values.

提示

使用此函数最便捷的方法是将其应用于 make-series 运算符的结果。The most convenient way of using this function is by applying it to the results of make-series operator.

示例Examples

print id=' ', x=range(bin(now(), 1h)-11h, bin(now(), 1h), 1h), y=dynamic([2,5,6,8,11,15,17,18,25,26,30,30])
| extend fit=series_fit_line_dynamic(y)
| extend RSquare=fit.rsquare, Slope=fit.slope, Variance=fit.variance,RVariance=fit.rvariance,Interception=fit.interception,LineFit=fit.line_fit
| render timechart

序列拟合线

RSquareRSquare 斜率Slope VarianceVariance RVarianceRVariance InterceptionInterception LineFitLineFit
0.9820.982 2.7302.730 98.62898.628 1.6861.686 -1.666-1.666 1.064、3.7945、6.526、9.256、11.987、14.718、17.449、20.180、22.910、25.641、28.371、31.1021.064, 3.7945, 6.526, 9.256, 11.987, 14.718, 17.449, 20.180, 22.910, 25.641, 28.371, 31.102