import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
#预测
def GM11(x,n):
'''
灰色预测
x:序列,numpy对象
n:需要往后预测的个数
'''
x1 = x.cumsum()#一次累加
z1 = (x1[:len(x1) - 1] + x1[1:])/2.0#紧邻均值
z1 = z1.reshape((len(z1),1))
B = np.append(-z1,np.ones_like(z1),axis=1)
Y = x[1:].reshape((len(x) - 1,1))
#a为发展系数 b为灰色作用量
[[a],[b]] = np.dot(np.dot(np.linalg.inv(np.dot(B.T, B)), B.T), Y)#计算待估参数
result = (x[0]
基于python 实现灰色预测以及预测图—HWH from DFZY
最新推荐文章于 2024-07-13 00:34:09 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)