# series_fit_2lines()series_fit_2lines()

`rsquare` 相关系数平方是衡量拟合质量的标准。R-square is 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 do not fit any line.
`split_idx` 两段的拆分点的索引（从零开始）。The index of breaking point to two segments (zero-based).
`variance` 输入数据的方差。Variance of the input data.
`rvariance` 剩余方差，即输入数据值和近似数据值之间的方差（按两个线段）。Residual variance, which is the variance between the input data values the approximated ones (by the two line segments).
`line_fit` 包含一系列最佳拟合线值的数值数组。Numerical array holding a series of values of the best fitted line. 序列长度等于输入数组的长度。The series length is equal to the length of the input array. 它主要用于绘制图表。It's mainly used for charting.
`right_rsquare` 拆分点右侧线的相关系数平方，请参阅 series_fit_line()R-square of the line on the right side of the split, see series_fit_line().
`right_slope` 右近似线（形式为 y=ax+b）的斜率。Slope of the right approximated line (of the form y=ax+b).
`right_interception` 左近似线的截距（即 y=ax+b 中的 b）。Interception of the approximated left line (b from y=ax+b).
`right_variance` 拆分点右侧输入数据的方差。Variance of the input data on the right side of the split.
`right_rvariance` 拆分点右侧输入数据的剩余方差。Residual variance of the input data on the right side of the split.
`left_rsquare` 拆分点左侧线的相关系数平方，请参阅 series_fit_line()R-square of the line on the left side of the split, see series_fit_line().
`left_slope` 左近似线（形式为 y=ax+b）的斜率。Slope of the left approximated line (of the form y=ax+b).
`left_interception` 左近似线（形式为 y=ax+b）的截距。Interception of the approximated left line (of the form y=ax+b).
`left_variance` 拆分点左侧输入数据的方差。Variance of the input data on the left side of the split.
`left_rvariance` 拆分点左侧输入数据的剩余方差。Residual variance of the input data on the left side of the split.

## 语法Syntax

project `series_fit_2lines(`x`)`project `series_fit_2lines(`x`)`

• 将会返回上述所有列，其名称为：series_fit_2lines_x_rsquare、series_fit_2lines_x_split_idx 等。Will return all mentioned above columns with the following names: series_fit_2lines_x_rsquare, series_fit_2lines_x_split_idx etc.

project (rs, si, v)=`series_fit_2lines(`x`)`project (rs, si, v)=`series_fit_2lines(`x`)`

• 将会返回以下列：rs（相关系数平方）、si（拆分索引）、v（方差），其余列的名称将会类似于 series_fit_2lines_x_rvariance、series_fit_2lines_x_line_fit 等。Will return the following columns: rs (r-square), si (split index), v (variance) and the rest will look like series_fit_2lines_x_rvariance, series_fit_2lines_x_line_fit and etc.

extend (rs, si, v)=`series_fit_2lines(`x`)`extend (rs, si, v)=`series_fit_2lines(`x`)`

• 将仅返回：rs（相关系数平方）、si（拆分索引）和 v（方差）。Will return only: rs (r-square), si (split index) and v (variance).

## 参数Arguments

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

## 示例Examples

``````print id=' ', x=range(bin(now(), 1h)-11h, bin(now(), 1h), 1h), y=dynamic([1,2.2, 2.5, 4.7, 5.0, 12, 10.3, 10.3, 9, 8.3, 6.2])
| extend (Slope,Interception,RSquare,Variance,RVariance,LineFit)=series_fit_line(y), (RSquare2, SplitIdx, Variance2,RVariance2,LineFit2)=series_fit_2lines(y)
| project id, x, y, LineFit, LineFit2
| render timechart
``````