用可编程科学计算器,怎样编写灰色预测模型GM(1,1)程序?

用可编程科学计算器,怎样编写灰色预测模型GM(1,1)程序?,第1张

分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard学苑。

今天小编为大家带来《快速上手灰色系统理论GM(1,1)模型》,一起来看看吧!

快速上手灰色系统理论GM(1,1)模型

01:53来自LearningYard学苑

多图预警!建议连接WIFI阅读!

【1】研究背景

灰色系统理论是由我国著名学者邓聚龙教授创立,是中国原创学科,是确定性理论和系统科学领域的重要学科。我们称部分信息已知,部分信息不明确的系统为灰色系统,通过对少量信息的累加、累减等计算处理,获取有价值的部分,实现对灰色系统变化趋势的预测,或者对当前系统状况的准确监控。如今灰色系统理论已经进过了将近40年的发展完善,成果丰硕,在理论体系和模型框架方面已经比较完善,参数优化和计算方法等方面都有了相当大的改进,已形成包含了系统分析、预测、优化等技术体系,在许多学科领域得到了广泛的应用。

GM(1,1)模型作为灰色系统理论重要组成部分,适合于小样本数据的预测,在样本缺乏导致信息不足的情况下能充分利用所观察到的决策信息,给出较高精度的预测结果。GM(1,1)模型的思想是对最开始的数据进行一次累加生成数据序列,新的数据序列相应的曲线可以应用特定曲线无限逼近,把逼近曲线作为基础模型,将预测值做几次滚动累加还原,以预测出发展趋势。

【2】基础概念

(1)灰色系统

灰色系统介于黑色系统与白色系统之间,称部分信息已知、另部分信息未知,且内部各因素间有不确定的关系的系统为灰色系统。

(2)灰色预测

灰色预测是通过少量的、不完全的信息,建立数学模型做出预测的一种预测方法。该方法基于客观事物的过去和现在的发展规律,对未来的发展趋势和状况进行描述和分析,并形成科学的假设和判断。其中GM(1,1)模型就是灰色预测中的强力工具之一。

(3)GM(1,1)模型

该模型中,G表示Grey,M表示Model,括号中第一个1代表一阶微分方程,第二个1代表微分方程有一个变量。同理,灰色预测理论中GM(1,2)表示有两个变量的一阶微分方程灰色模型。

【3】基于GM(1,1)模型的灰色预测步骤

令不完全信息非负序列为X(0),生成1-AGO(1-Accumulating Generation Operational)序列X(1)。1-AGO序列类似帕累托图中的累加折线。

利用高数知识构建GM(1,1)模型的灰色微分方程,其中a为发展系数,b为灰色作用量。通过公式得到均值形式的GM(1,1)模型Z(1)。

构建灰色预测矩阵:

通过最小二乘法构建函数,并求出估计值:

GM(1,1)模型的白化微分方程为:

得到在公式(1)条件下时间响应函数,并对公式(7)进行计算,得到模拟预测序列。

【英语学习】

Grey system theory was founded by the famous Chinese scholar Professor Deng Julong. It is an original subject in China and an important subject in the field of deterministic theory and systems science. We call a system with some known information and some unclear information as a gray system. By accumulating and subtracting a small amount of information, we can obtain valuable parts to predict the changing trend of the gray system or the current system status. Accurate monitoring. Now the grey system theory has been developed and perfected for nearly 40 years, with fruitful results. It has been relatively complete in terms of theoretical system and model framework, and considerable improvements have been made in parameter optimization and calculation methods, and it has been formed to include system analysis. Technical systems such as, forecasting, and optimization have been widely used in many disciplines. As an important part of gray system theory, GM(1,1) model is suitable for the prediction of small sample data. It can make full use of the observed decision information when the lack of samples leads to insufficient information, and give high-precision prediction results . The idea of the GM(1,1) model is to accumulate the initial data once to generate a data sequence. The corresponding curve of the new data sequence can be approximated infinitely by a specific curve. The approximate curve is used as the basic model and the predicted value is rolled several times. Accumulate reduction to predict the development trend.

本期的分享就到这里,如果您对今天的文章有独特的想法,欢迎给我们留言,让我们相约明天,祝您今天过得开心快乐!

本文由LearningYard学苑原创,仅代表作者个人观点,如有侵权请联系删除。

翻译参考来源:Google翻译。

内容参考来源:

[1] Liu S , Yin C , Cao D . Weapon equipment management cost prediction based on forgetting factor recursive GM (1,1) model[J]. Grey Systems Theory &Application, 2019, 10(1):38-45.

clc

clear all

% 本程序主要用来计算根据灰色理论建立的模型的预测值。

% 应用的数学模型是 GM(1,1)。

% 原始数据的处理方法是一次累加法。

y=[1662.87 2163.4 1965.35 2472.48 2900.66 3034.93 2755.5 3207 3462]%已知数据

n=length(y)

yy=ones(n,1)

yy(1)=y(1)

for i=2:n

yy(i)=yy(i-1)+y(i)

end

B=ones(n-1,2)

for i=1:(n-1)

B(i,1)=-(yy(i)+yy(i+1))/2

B(i,2)=1

end

BT=B'

for j=1:n-1

YN(j)=y(j+1)

end

YN=YN'

A=inv(BT*B)*BT*YN

a=A(1)

u=A(2)

t=u/a

t_test=4  %需要预测个数

i=1:t_test+n

yys(i+1)=(y(1)-t).*exp(-a.*i)+t

yys(1)=y(1)

for j=n+t_test:-1:2

ys(j)=yys(j)-yys(j-1)

end

x=1:n

xs=2:n+t_test

yn=ys(2:n+t_test)

plot(x,y,'^r',xs,yn,'*-b')

det=0

for i=2:n

det=det+abs(yn(i)-y(i))

end

det=det/(n-1)

disp(['百分绝对误差为:',num2str(det),'%'])

disp(['预测值为: ',num2str(ys(n+1:n+t_test))])

输出结果:

百分绝对误差为:228.3113%

预测值为: 3710.152      3978.2142      4265.6442      4573.8413

这是我曾经写过的一个灰色预测的程序:第一个文件为函数,需要在调用时输入原始数据x0和预测周期T, 第二个文件用于计算灰色关联度,使用时直接修改相关参数和原始数据。

--------------------------------------------------------------------------

第一个文件(用于灰色建模):grymdl.m

--------------------------------------------------------------------------

function GM=grymdl(x0,T)

% 输入原始数据x0

% T为从最后一个历史数据算起的第T时点

x1=zeros(1,length(x0))B=zeros(length(x0)-1,2)

yn=zeros(length(x0)-1,1)Hatx0=zeros(1,length(x0)+T)

Hatx00=zeros(1,length(x0))Hatx1=zeros(1,length(x0)+T)

epsilon=zeros(length(x0),1)omega=zeros(length(x0),1)

for i=1:length(x0)

    for j=1:i

        x1(i)=x1(i)+x0(j)

    end

end

for i=1:length(x0)-1

    B(i,1)=(-1/2)*(x1(i)+x1(i+1))

    B(i,2)=1

    yn(i)=x0(i+1)

end

HatA=(inv(B'*B))*B'*yn %GM(1,1)模型参数估计

for k=1:length(x0)+T

    Hatx1(k)=(x0(1)-HatA(2)/HatA(1))*exp(-HatA(1)*(k-1))+HatA(2)/HatA(1)

end

Hatx0(1)=Hatx1(1)

for k=2:length(x0)+T

    Hatx0(k)=Hatx1(k)-Hatx1(k-1)%累计还原得到历史数据的模拟值

end

for i=1:length(x0) %开始模型检验

    epsilon(i)=x0(i)-Hatx0(i)

    omega(i)=(epsilon(i)/x0(i))*100

end

x0

HatA

Hatx0

epsilon

omega

c=std(epsilon)/std(x0)

p=0

for i=1:length(x0)

    if abs(epsilon(i)-mean(epsilon))<0.6745*std(x0)

        p=p+1

    end

end

p=p/length(x0)

if p>=0.95

    M1=1

elseif p>=0.8

    M1=2

elseif p>=0.7

    M1=3

else

    M1=4

end

if c<=0.35

    M2=1

elseif c<=0.5

    M2=2

elseif c<=0.65

    M2=3

else

    M2=4

end

M=max(M1,M2)

if M==1

    disp('The model is good,and the forecast is:'),

    disp(Hatx0(length(x0)+T))

elseif M==2

    disp('The model is eligibility,and the forecast is:'),

    disp(Hatx0(length(x0)+T))

elseif M==3

    disp('The model is not good,and the forecast is:'),

    disp(Hatx0(length(x0)+T))

else

    disp('The model is bad and try again')

    disp(Hatx0(length(x0)+T))

end

for i=1:length(x0)

    Hatx00(i)=Hatx0(i)

end

z=1:length(x0)

plot(z,x0,'-',z,Hatx00,'*:') %将原始数据和模拟值画在一个图上帮助观察

text(2,x0(2),'History data: real line')

text(length(x0)/2,Hatx00(length(x0))/2,'Simulation data:broken line')

GM=Hatx0(length(x0)+T)

--------------------------------------------------------------------------------

第二个文件(用于计算灰色关联度):grydgr.m

--------------------------------------------------------------------------------

x=[26.4,40.83,5,18.5,27,4.9

    32.56,50.36,6.5,23.8,34.9,5.97

    41.16,63.66,7.9,30.6,45,6.83

    51.82,80.15,9.6,39.43,60.76,8.21

    70.58,109.16,11.3,52.1,81.8,9.78

    111.47,136.12,15,73.92,118.12,12.3

    127.16,166.7,18,118.17,184.51,16.75

    165.99,196.91,20.66,156.65,240.83,21.49

    246.76,257.56,24.15,218.3,333.4,27.1] %原始数据

delta=zeros(size(x,1),size(x,2)-1) %初始化绝对差

yita=zeros(size(delta,1),size(delta,2)) %初始化关联系数

for i=1:size(x,2)

    x(:,i)=x(:,i)./x(1,i)  %无量纲化处理

end

for i=1:(size(x,2)-1)

    delta(:,i)=abs(x(:,1)-x(:,i+1))  %求解delta

end

delta_min=min(min(delta,[],1)) %求解最小二级差

delta_max=max(max(delta,[],1)) %求解最大二级差

rou=0.5 %设定分辨系数为0.5

for i=1:size(delta,1)

    for j=1:size(delta,2)

        yita(i,j)=(delta_min+rou*delta_max)/(delta(i,j)+rou*delta_max) %计算关联系数

    end

end

r=sum(yita)./size(yita,1) %计算灰色关联


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/11153180.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存