资源描述:
《基于VB的_灰色模型预测_和_线性回归预测》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、灰色模型预测GM(1,1)与线性回归预测(一元、多元)新建一个工程,添加一个模块(.bas),两个命令按钮:窗体代码:OptionExplicitPrivateSubCommand1_Click()'灰色模型预测DimDataAsStringData="2.67,3.13,3.25,3.36,3.56,3.72"GM1_1_PredictDataEndSubPrivateSubCommand2_Click()'线性回归预测DimX1AsString,X2AsString,X3AsString,X4AsString,YAsStringX1="100.38,99.7,92.3,8
2、7.6,87.17,88.3,92.75,100.6,90.05;"'最后要加上分号;X2="53.24,51.5,50.5,52.4,59.6,59.7,65.2,62.4,53.68;"'最后要加上分号;X3="226,250,281,272,194,180,105,115,250;"'最后要加上分号;Y="644,640,517,425,385,401,448,599,462"'最后不要加上分号;请注意!!!Linear_Regression_PredictX1&X2&X3&YEndSub模块代码:OptionExplicitPrivateSubCalculate_1_
3、AGO(X_0()AsDouble,X_1()AsDouble)'做一次累加生成1-AGODimiAsLong,TempXAsDouble,KAsLongK=UBound(X_0)ReDimX_1(K)Fori=0ToKTempX=TempX+X_0(i)X_1(i)=TempXNextiEndSubPrivateSubCalculate_Matrix_B(X_1()AsDouble,B()AsDouble)'计算数据矩阵BDimiAsLong,KAsLongK=UBound(X_1)-1ReDimB(K,1)Fori=0ToKB(i,0)=-0.5*(X_1(i)+X_1(
4、i+1))B(i,1)=1NextiEndSubPrivateSubCalculate_Matrix_YN(X_0()AsDouble,YN()AsDouble)'计算数据矩阵YNDimiAsLong,KAsLongK=UBound(X_0)-1ReDimYN(K,0)Fori=0ToKYN(i,0)=X_0(i+1)NextiEndSub''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
5、''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''函数名:Matrix_Transpotation'功能:计算矩阵的转置transpotation'参数:m-Integer型变量,矩阵的行数'n-Integer型变量,矩阵的列数'mtxA-Double型mxn二维数组,存放原矩阵'mtxAT-Double型nxm二维数组,返回转置矩阵''''''
6、''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''PrivateSubMatrix_Transpotation(mtxA()
7、AsDouble,mtxAT()AsDouble)DimiAsInteger,jAsIntegerDimMAsInteger,NAsIntegerM=UBound(mtxA,2)N=UBound(mtxA,1)ReDimmtxAT(M,N)Fori=0ToMForj=0ToNmtxAT(i,j)=mtxA(j,i)NextjNextiEndSub''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''