Joke Collection Website - Talk about mood - Talking about mathematical codes

Talking about mathematical codes

Grey prediction

x =[0. 1 1 0.49 0.50 0.23 0.27 0.02-0.02 0.26-0.25 0.08 ...

0.52 0. 13 -0.0 1 0.52 0.57 0.0 1 0.32 -0. 15 0.45 0.07 0.66 ...

0.58 0.5 1 0.53 0.49 0.38 0.33 0.29 0.32 0.03 0.39];

Long format; % Set the calculation accuracy

If length (x (:,1)) =1%determines the input matrix, if it is not a one-dimensional column matrix, transpose it.

x = x’;

end

N = length (x); % take the sample size of input data.

z = 0;

For i= 1:n%, the cumulative value is calculated and assigned to the matrix be.

z=z+x(i,);

be(i,)= z;

end

The original sequence is shifted in parallel for i=2:n%.

y(i- 1,)=x(i,);

end

Calculate the data in the first column of data matrix B for i= 1:n- 1%.

c(i,)=-0.5*(be(i,)+be(i+ 1,);

end

Calculate the data in the second column of data matrix B for j= 1:n- 1%.

e(j,)= 1;

end

The data matrix b is constructed for i= 1:n- 1%.

B(i, 1)=c(i,);

B(i,2)=e(i,);

end

alpha = inv(B ' * B)* B ' * y; % calculation parameter matrix

For i= 1:n+ 1% Calculate the cumulative series of estimated values of data. If it is predictable, change n+ 1 to n+m+ 1.

ago(i,:=(x( 1,:)-alpha(2,:)/alpha( 1,:)*exp(-alpha( 1,:)(i- 1))+alpha(2,:)/alpha( 1,:);

end

var( 1,)=ago( 1,)

For i= 1:n% If n is changed to n+m- 1, the last m- 1 values can be predicted.

var(i+ 1,:)=ago(i+ 1,:)-ago(i,:); % of the estimated value, and calculate the next prediction.

end

For i= 1:n

error(i,)=var(i,)-x(i,); % calculation residual

end

C=std (error) /std(x)% Call the standard deviation function of the statistical toolbox to calculate the ratio of the variance after the test.