1 Star 4 Fork 11

王布衣 / pandas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
forcast.go 477 Bytes
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-02-14 08:08 . !59#I6F1P2优化序列处理方式
package formula
import (
"gitee.com/quant1x/pandas/stat"
)
// FORCAST 返回S序列N周期回线性回归后的预测值
func FORCAST(S stat.Series, N any) any {
return S.Rolling(N).Apply(func(X stat.Series, W stat.DType) stat.DType {
x := X.DTypes()
ws := stat.Range[float64](int(W))
c := stat.PolyFit(ws, x, 1)
w1 := stat.Repeat[float64](W-1, int(W))
vs := stat.PolyVal(c, w1)
if W > 1 {
return vs[0]
} else {
return stat.DTypeNaN
}
}).Values()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/pandas.git
git@gitee.com:quant1x/pandas.git
quant1x
pandas
pandas
v0.6.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891