怎么会呢塔利布利纳雷格作品?

2024-09-29 23:16:20 发布

您现在位置:Python中文网/ 问答频道 /正文

另外,我现在的问题是,我是否要在两个数组上回归,例如不等距无序

x = np.array([0.1, 0.5, 2.0, 1.6, 2.8, 3.5, 0.9, 1.5])
y = np.array([0.22, 1.21, 4.19, 3.39, 5.85, 7.21, 2.0, 3.2])

在talib中使用LINEARREG函数应该怎么做?在


感谢truf指出的c代码链接,LINEARREG只处理euqal距离x数组,而只通过输入y数组进行回归(此处价格接近)。在

^{pr2}$

还应该注意,输入numpy数组需要进行类型检查

dtype=np.float

与c中的“double”匹配


original question

我用TA-Lib来计算技术指标,但是我不明白LINEARREG函数只有一个输入数组(称为收盘价),通常做线性回归,我们需要两个数组x和y来回归,比如我们要回归收盘价。在

实数=LINEARREG(关闭,时间段=14)


Tags: 函数代码距离链接np价格数组array
1条回答
网友
1楼 · 发布于 2024-09-29 23:16:20

您最好检查ta lib中此函数的代码: https://sourceforge.net/p/ta-lib/code/HEAD/tree/trunk/ta-lib/c/src/ta_func/ta_LINEARREG.c#l238
它包含以下解释:

   /* Linear Regression is a concept also known as the
* "least squares method" or "best fit." Linear
* Regression attempts to fit a straight line between
* several data points in such a way that distance
* between each data point and the line is minimized.
*
* For each point, a straight line over the specified
* previous bar period is determined in terms
* of y = b + m*x:
*
* TA_LINEARREG          : Returns b+m*(period-1)
* TA_LINEARREG_SLOPE    : Returns 'm'
* TA_LINEARREG_ANGLE    : Returns 'm' in degree.
* TA_LINEARREG_INTERCEPT: Returns 'b'
* TA_TSF                : Returns b+m*(period)
*/

看来你的收盘价将被视为y数组,x将是日数数组[1..14]。tau linearerg_SLOPE、TA_LINEARREG_ANGLE、TA_LINEARREG_INTERCEPT和TA_TSF是其他基于TA_LINEARREG的TA lib函数。在

相关问题 更多 >

    热门问题