线性回归法.m
上传用户:yetwld
上传日期:2010-01-26
资源大小:82k
文件大小:9k
源码类别:

TAPI编程

开发平台:

Matlab

  1. %建模数据集,123×8
  2. mg_data=[0.09072 -0.59068 -0.88776 -0.51421 -0.059731 1.2648 -0.52864 2.3373;
  3. -0.32361 0.94281 -0.88776 -0.68304 0.63656 -0.023082 0.47974 -0.60184;
  4. -0.32361 -0.33509 -0.53823 -0.34538 -0.40788 0.17513 0.59178 -0.46824;
  5. 2.5767 -0.33509 -1.2373 -1.0207 -0.66899 1.0666 1.4881 -0.33464;
  6. 0.09072 0.94281 0.85989 -0.34538 -0.40788 0.6702 1.3761 -0.73544;
  7. -0.53078 -0.079514 -1.2373 -0.68304 -0.49492 1.2648 1.9363 -0.60184;
  8. -0.32361 0.68723 -0.53823 -0.17655 0.20138 -0.61771 -0.30456 -0.46824;
  9. -0.11645 0.68723 0.16083 -0.51421 -1.2782 -1.1137 -0.080472 -1.4034;
  10. -0.53078 -0.84626 0.16083 -0.85187 0.46249 -1.5101 -1.3129 -0.46824;
  11. -0.73794 -0.079514 0.16083 -0.0077242 0.027306 -1.0141 -0.75272 -0.46824;
  12. -0.53078 0.94281 0.16083 -1.0207 -0.49492 -1.1137 -1.0889 -0.20104;
  13. -0.53078 0.68723 -0.53823 -0.68304 0.37545 -0.81591 -0.30456 -0.73544;
  14. -0.11645 0.94281 0.16083 -0.34538 -0.49492 -1.1137 -0.86477 -0.46824;
  15. -0.73794 0.94281 0.16083 -0.34538 -0.84306 -1.6087 -1.0889 -0.86904;
  16. -0.53078 0.94281 -1.9363 -1.1895 -1.3653 -1.9065 0.3677 -3.0066;
  17. -0.73794 0.68723 -0.88776 -0.68304 -0.40788 -2.5011 -0.52864 -2.7394;
  18. -0.32361 -1.8686 -0.88776 -0.85187 -0.49492 0.76887 -0.97681 2.2037;
  19. 2.7839 -0.59068 -1.5868 -0.34538 -1.0171 -0.61771 0.25565 -1.1362;
  20. 0.91938 -0.33509 -1.9363 -1.3584 -0.84306 -0.51904 0.59178 -1.4034;
  21. 0.09072 -0.59068 -0.88776 -1.5272 -1.1912 -0.32083 0.70382 -1.2698;
  22. -0.53078 0.43165 -0.88776 -0.68304 -0.66899 -0.71725 0.03157 -1.0026;
  23. 0.29789 0.17607 0.51036 -0.85187 -0.75603 0.86841 0.59178 0.46695;
  24. -0.73794 0.94281 0.85989 -0.51421 -1.0171 -0.023082 -0.4166 0.46695;
  25. 0.29789 0.68723 0.51036 -1.1895 -1.0171 0.57154 -0.19251 1.0013;
  26. -0.73794 -0.079514 0.16083 -0.51421 -0.58195 -0.12263 -1.0889 1.1349;
  27. -0.53078 1.1984 0.16083 -1.0207 -0.84306 -0.22217 -0.52864 0.33335;
  28. -0.94511 0.17607 0.85989 -1.0207 -1.1912 -0.91546 -1.425 0.46695;
  29. -0.11645 0.17607 0.16083 -0.0077242 -0.49492 -0.32083 -1.2009 1.0013;
  30. -0.32361 1.1984 -0.1887 -1.1895 -1.5394 -1.4105 -1.2009 -0.46824;
  31. -0.11645 0.43165 -0.1887 -1.696 -1.4523 -1.2132 -1.3129 -0.067445;
  32. -0.32361 -0.33509 -1.2373 -0.51421 -1.1912 -1.2132 -1.0889 -0.33464;
  33. -0.53078 0.68723 0.85989 -0.85187 -0.84306 -0.32083 -1.2009 1.0013;
  34. -0.94511 1.454 0.85989 -1.5272 -1.1912 -1.3119 -1.3129 -0.20104;
  35. 0.29789 0.17607 0.16083 -1.0207 -1.3653 -0.51904 -1.0889 0.60055;
  36. -0.73794 0.17607 -0.53823 -0.68304 -0.84306 -0.32083 -0.75272 0.46695;
  37. -0.53078 1.1984 0.85989 -0.0077242 -0.84306 -1.807 -0.97681 -1.2698;
  38. -0.11645 0.94281 1.9085 -0.51421 -1.5394 -0.51904 -1.2009 0.73415;
  39. -0.73794 1.7096 0.85989 -0.68304 -1.0171 -1.4105 -0.97681 -0.73544;
  40. -0.53078 0.17607 -1.2373 -0.68304 -0.40788 -0.61771 -0.97681 0.33335;
  41. -0.53078 0.68723 0.85989 -0.68304 -0.66899 -1.1137 -1.0889 -0.20104;
  42. -0.94511 1.454 -0.1887 -1.696 -0.84306 -0.91546 -0.97681 -0.067445;
  43. -0.94511 0.68723 1.5589 -0.68304 0.11434 0.17513 -0.97681 1.4021;
  44. -0.94511 -1.1018 0.85989 -0.51421 -0.40788 -0.81591 -1.425 0.60055;
  45. -0.94511 0.94281 0.85989 -0.34538 -0.75603 -1.6087 -1.3129 -0.60184;
  46. 2.991 0.68723 -1.5868 0.32994 0.46249 0.17513 0.47974 -0.33464;
  47. 1.9552 0.17607 -0.88776 -0.34538 -0.32084 1.0666 0.14361 1.2685;
  48. -0.73794 0.43165 1.9085 2.0182 1.4199 -0.61771 -0.75272 0.066153;
  49. 3.6125 0.17607 -1.5868 1.1741 0.20138 0.27379 1.264 -1.1362;
  50. 4.0269 -1.3574 -1.9363 -0.0077242 -0.49492 1.463 1.7122 -0.067445;
  51. 0.91938 0.17607 0.16083 -0.0077242 0.20138 0.472 0.92791 -0.46824;
  52. -0.94511 -0.079514 -0.53823 1.0053 1.594 1.0666 -0.64068 2.2037;
  53. -0.53078 0.17607 -0.88776 -0.68304 -0.32084 0.27379 1.264 -1.1362;
  54. -0.94511 -0.59068 -0.88776 2.0182 2.1162 0.472 0.14361 0.46695;
  55. -0.32361 -0.59068 -0.88776 2.3559 2.1162 0.96796 0.25565 1.0013;
  56. -0.94511 -1.3574 0.85989 2.8624 2.4643 0.6702 1.0399 -0.33464;
  57. -0.73794 -1.8686 -0.53823 2.3559 2.2903 1.2824 1.264 0.2235;
  58. 0.91938 1.1984 0.85989 0.49877 0.7236 -0.61771 0.03157 -0.86904;
  59. 1.5409 -0.84626 -0.1887 1.0053 -0.14677 0.17513 0.14361 0.066153;
  60. -0.53078 -1.613 -1.5868 2.0182 1.9421 0.86841 1.0399 -0.067445;
  61. -0.11645 -1.3574 -0.53823 2.5247 1.2458 1.2648 0.70382 0.86774;
  62. -0.73794 -0.079514 0.85989 1.0053 1.3329 0.075581 0.59178 -0.60184;
  63. 1.5409 -0.079514 0.16083 0.66759 0.7236 0.472 1.152 -0.73544;
  64. -0.94511 0.43165 1.5589 1.0053 1.2458 0.57154 -1.2009 2.2037;
  65. 0.29789 0.94281 1.9085 -1.0207 -0.14677 0.27379 -0.52864 1.0013;
  66. -0.11645 -0.079514 0.85989 -0.0077242 0.027306 -0.4195 -0.080472 -0.46824;
  67. 2.1624 1.1984 -0.1887 -0.85187 -0.75603 0.27379 1.0399 -0.86904;
  68. 2.7839 -1.613 1.2094 1.3429 0.89767 1.3644 1.264 0.33335;
  69. 0.91938 0.17607 -0.53823 -0.34538 -0.32084 0.96796 0.3677 -1.4034;
  70. 1.3337 -2.6353 0.16083 1.3429 1.2458 1.463 1.7122 -0.067445;
  71. -0.11645 -1.3574 -1.5868 2.5247 1.594 0.86841 1.264 -0.33464;
  72. -0.32361 -0.59068 -2.6354 -0.68304 -0.49492 -0.12263 0.59178 -0.86904;
  73. 0.71222 -0.33509 0.16083 0.66759 2.1162 0.37333 0.03157 0.46695;
  74. 0.91938 -0.59068 -0.1887 -0.34538 -0.40788 0.17513 0.47974 -0.33464;
  75. 0.50505 -1.3574 -0.53823 1.3429 1.594 0.86841 1.4881 -0.60184;
  76. -0.11645 -1.8686 0.51036 1.3429 1.594 -0.51904 -0.51619 -0.08229;
  77. -0.73794 -1.8686 -0.1887 -0.34538 -0.49492 0.6702 -0.4166 1.4021;
  78. 0.50505 -0.59068 -0.1887 0.16111 0.027306 1.0666 0.3677 1.0013;
  79. 1.5409 -2.6353 -0.88776 -0.0077242 0.37545 1.1662 0.47974 1.0013;
  80. 1.3337 -0.33509 -0.53823 1.3429 2.2903 1.2648 1.6002 -0.20104;
  81. 0.09072 -1.3574 -1.5868 1.6806 2.1162 0.96796 0.3677 0.86774;
  82. 0.09072 0.68723 0.85989 0.16111 0.7236 -0.91546 0.14361 -1.4034;
  83. 0.91938 -0.84626 0.16083 0.32994 0.11434 0.57154 0.81586 -0.20104;
  84. -0.11645 -0.59068 0.85989 0.83642 1.0717 -0.023082 0.14361 -0.20104;
  85. 0.71222 -0.59068 -0.53823 1.6806 1.4199 0.96796 1.264 -0.20104;
  86. 0.09072 0.17607 -1.2373 1.3429 2.0292 -0.023082 0.59178 -0.73544;
  87. -0.94511 -1.3574 1.2094 -0.0077242 -0.84306 -0.91546 -0.4166 -0.73544;
  88. -0.73794 -0.079514 0.85989 0.66759 0.7236 -1.0141 -0.19251 -1.1362;
  89. -0.32361 -1.3574 0.51036 0.32994 0.7236 0.075581 0.25565 -0.20104;
  90. 0.50505 -1.8686 -1.2373 1.0053 2.1162 1.2648 0.92791 0.60055;
  91. -0.53078 -0.84626 0.16083 0.32994 1.768 0.27379 0.14361 0.19975;
  92. -0.73794 0.68723 1.2094 0.32994 -0.14677 -1.9065 -0.30456 -2.205;
  93. -0.94511 0.68723 0.85989 1.3429 1.4199 -1.7083 -0.4166 -1.8042;
  94. -0.32361 -0.33509 2.9571 -0.17655 0.37545 -1.9065 -1.1137 -1.2401;
  95. -0.53078 0.68723 2.258 -0.17655 -0.40788 -1.2132 -0.64068 -0.86904;
  96. -0.73794 -0.84626 0.51036 0.66759 0.37545 -0.4195 -0.64068 0.19975;
  97. 0.91938 -0.59068 0.16083 -0.51421 -0.14677 -0.32083 0.03157 -0.46824;
  98. 3.4054 -0.33509 -0.53823 -0.51421 -0.32084 0.57154 1.0399 -0.46824;
  99. -0.94511 0.43165 1.5589 0.66759 0.46249 -0.71725 0.14361 -1.1362;
  100. -0.53078 0.43165 0.51036 0.32994 -0.40788 0.472 1.7122 -1.4034;
  101. -0.11645 0.17607 1.2094 0.66759 0.027306 0.17513 2.1604 -2.3386;
  102. 0.29789 0.68723 0.16083 -0.34538 0.54953 -0.023082 -0.86477 1.0013;
  103. -0.73794 -0.079514 0.16083 -0.34538 0.20138 -0.51904 -0.86477 0.33335;
  104. 0.29789 1.1984 1.5589 0.83642 0.54953 -0.023082 0.25565 -0.33464;
  105. -0.73794 0.94281 1.2094 -0.0077242 -0.14677 -1.4105 -0.080472 -1.8042;
  106. -0.53078 0.68723 1.2094 1.0053 0.46249 0.27379 -0.52864 1.0013;
  107. -0.53078 0.94281 0.85989 0.32994 1.0717 -1.1137 -0.64068 -0.73544;
  108. 0.09072 0.17607 1.2094 -0.0077242 -0.32084 0.76887 -0.19251 1.2685;
  109. 0.71222 -0.079514 0.16083 -0.51421 -0.059731 -0.32083 -0.75272 0.46695;
  110. -0.53078 -0.079514 1.2094 -0.0077242 -0.58195 0.27379 -0.080472 0.46695;
  111. -0.32361 -0.33509 0.16083 0.49877 -0.059731 -0.4195 0.14361 -0.73544;
  112. 0.91938 -0.33509 -0.1887 -0.34538 -0.32084 -0.12263 -0.19251 0.066153;
  113. -0.73794 -0.33509 0.16083 -0.34538 -0.58195 0.075581 0.25565 -0.20104;
  114. 0.09072 -0.84626 0.16083 2.0182 1.2458 1.1662 0.14361 1.4021;
  115. -0.73794 -1.8686 0.16083 0.83642 0.89767 1.0666 0.70382 0.60055;
  116. -0.73794 -2.3797 -2.6354 0.66759 0.54953 0.76887 2.3845 0.19975;
  117. 0.09072 -0.84626 -1.5868 1.0053 1.2458 2.0577 2.0483 0.33335;
  118. 1.9552 -2.1242 -0.53823 2.1871 1.4199 2.8505 2.3845 1.0013;
  119. 0.91938 -0.079514 -1.5868 1.1741 0.89767 2.1563 2.7206 -0.33464;
  120. 0.50505 -0.59068 -1.5868 0.49877 1.2458 2.7509 2.1604 1.1349;
  121. 0.91938 -1.1018 -1.2373 0.16111 -0.84306 2.1563 2.2724 0.19975;
  122. -0.73794 0.17607 1.2094 1.0053 0.7236 0.37333 -0.4166 1.0013;
  123. -0.11645 -0.84626 1.5589 1.3429 0.37545 -0.51904 -0.97681 0.46695;
  124. -0.32361 -1.613 0.51036 2.3559 1.768 0.075581 -0.080472 0.19975];
  125. %多元线性回归建模
  126. n=length(mg_data);
  127. X=[ones(123,1),mg_data(:,1:8)]; 
  128.  %
  129.  %定义期望输出Y(主导变量:出池时的淀粉量)
  130.  Y=mg_data0(:,8); 
  131.  %求取回归系数距阵A
  132.  A=XY;
  133.  %估计值yy
  134.  yy=X*A;
  135.  %绝对误差(残差)
  136.  e=Y-yy;
  137.  %定义误差性能函数,评价预测模型的拟合能力
  138.  YSSE=e'*e             %误差平方和函数   YSSE = 27.2174
  139.  YMSE=YSSE/n           %均方误差函数  YMSE =0.7162
  140.  %绘制出实际输出与预测输出的拟合曲线
  141.  figure;
  142.  plot(g_data0(:,8),'r');
  143.  hold on;
  144.  plot(yy,'--');
  145.  legend('化验值','估计值');
  146.  title('多元线性回归模型输出拟合曲线');
  147.  xlabel('输入样本点');
  148.  ylabel('淀粉利用率');