时间序列趋势判断(三)——Mann-Kendall趋势检验

为了便于理解,可以参考B站的一个视频:https://www.bilibili.com/video/BV1tr4y1y7it

示例代码

为了简便,我们这里使用第三方库:

安装方法:

pip install pymannkendall

pyMannKendall github地址:https://github.com/mmhs013/pyMannKendall

使用的代码如下:

import numpy as np


def mk_test(data):
    """MK检验
    """
    import pymannkendall

    result = pymannkendall.original_test(data)
    return result.trend


if __name__ == '__main__':
    data = np.array([1, 2, 3, 4, 3, 5, 5, 7, 4, 7, ])
    print(mk_test(data))

参考文章

时间序列分析之趋势判断:https://www.biaodianfu.com/detect-trend-increasing-or-decreasing-in-time-series.html#%E6%96%B9%E6%A1%88%E5%9B%9B%EF%BC%9AMannKendall%E8%B6%8B%E5%8A%BF%E6%A3%80%E9%AA%8C%E6%B3%95

猜你喜欢

转载自blog.csdn.net/weixin_35757704/article/details/121719117