Gray prediction GM (1, 1)

Source: Internet
Author: User

% This program is mainly used to calculate the predicted value of the model based on the gray theory.
% The applied mathematical model is GM (1, 1 ).
% The raw data processing method is an accumulation method. Y = input ('Enter the data'); % enter the data in the format shown in the example: [48.7 57.17 68.76 92.15]
N = length (y );
YY = ones (n, 1 );
YY (1) = y (1 );
For I = 2: N
Y (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/;
T_test = input ('Enter the number of expected predictions :');
I = 1: t_test + N;
Yys (I + 1) = (Y (1)-T). * exp (-A. * I) + T;
Yys (1) = y (1 );
For J = N + t_test :-

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 (['absolute percentage error: ', num2str (DET),' % ']);
Disp (['predicted value: ', num2str (YS (n + 1: N + t_test)]);
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.