matlab实践(五):灰色估计法及最小二乘法准则

1.题目

\begin{cases}\dfrac{ds_1\left(t\right)}{dt}=\lambda_{_{10}s_1}+\lambda_{_{11}s^2_1}+\lambda_{_{12}s_1s_2}+\lambda_{_{13}s_1s_3}\\\dfrac{ds_2\left(t\right)}{dt}=\lambda_{_{20}s_2}+\lambda_{_{22}s^2_2}+\lambda_{_{21}s_1s_2}+\lambda_{_{23}s_2s_3}\\\dfrac{ds_3\left(t\right)}{dt}=\lambda_{_{30}s_3}+\lambda_{_{33}s^2_3}+\lambda_{_{31}s_1s_3}+\lambda_{_{32}s_2s_3}\end{cases}

2.灰色估计

利用灰导数与偶对数的映射关系将其化简为以下式子

s_{1}(t+1)-s_{1}(t)=\lambda_{10}\frac{s_{1}(t+1)+s_{1}(t)}{2}+\lambda_{11}\left[\frac{s_{1}(t+1)+s_{1}(t)}{2}\right]^{2}+\lambda_{12}\frac{\left[s_{1}(t+1)+s_{1}(t)\right]\left[s_{2}(t+1)+s_{2}(t)\right]}{4}+\lambda_{13}\frac{\left[s_{1}(t+1)+s_{1}(t)\right]\left[s_{3}(t+1)+s_{3}(t)\right]}{4}

同理得到剩余三个式子。

3.最小二乘准则

J(a)=|e|^{2}=|Ya-b|^{2}

\varphi (J)=0

\dot{a}=(Y^{T}Y)^{-1}Y^{T}b

4.代码

clc;clear;
X=xlsread('数据.xlsx');
x1=X(:,2);
x2=X(:,3);
x3=X(:,4);

 for i=1:n-1
        x11(i)=x1(i+1)-x1(i);
        x12(i)=x1(i+1)+x1(i);
        x21(i)=x2(i+1)-x2(i);
        x22(i)=x2(i+1)+x2(i);
        x31(i)=x3(i+1)-x3(i);
        x32(i)=x3(i+1)+x3(i);
    end
    %求方城常数
    A1=x11;
    %求方程系数
    B11=x12./2;
    B12=(x12.^2)./4;
    B13=(x12.*x22)./4;
    B14=(x12.*x32)./4;
    B1=[B11',B12',B13',B14'];
    % 最小二乘法准则
    U1=inv(B1'*B1)*B1'*A1';

    A2=x21;
    B21=x22./2;
    B22=(x22.^2)./4;
    B23=x12.*x22./4;
    B24=x22.*x32./4;
    B2=[B21',B22',B23',B24'];
    U2=inv(B2'*B2)*B2'*A2';

    A3=x31;
    B31=x32./2;
    B32=(x32.^2)./4;
    B33=x12.*x32./4;
    B34=x22.*x32./4;
    B3=[B31',B32',B33',B34'];
    U3=inv(B3'*B3)*B3'*A3';

    U{k}=[U1';U2';U3'];

你可能感兴趣的:(MATLAB,最小二乘法,算法,机器学习)