作者weiching0323 (许惟妮)
看板FJU-STAT95B
标题[专业] 6/8无母数课堂笔记14:40-15:30
时间Tue Jun 8 15:04:17 2010
**前置作业**
先至记事本 打入以下DATA
36 20
41 25
39 24
42 25
49 32
40 22
48 28
39 22
45 30
44 28
35 21
37 23
42 26
34 21
32 15
然後存在devcpp 档名打anacova.dat
然後即可开启C++
**前置作业结束**
===================================开始复制===================================
#include <C:\devcpp\all.h>
int main()
{
long int i, j;
srand((unsigned)time(NULL));
cout.setf(ios::fixed); cout.precision(10);
// $$$$$$$$ Start your program here $$$$$$$$$$$$$$$$$$$$$
Matrix Y;
Y.read_from_file("c:\\devcpp\\anacova.dat",2);
Y.print(0);
Matrix X2;
Y.split_column(Y,1,X2);
Y.print(0); X2.print(0);
Matrix D = gen_dummy(One_way_class(3,5));
D.print(0);
Matrix SST, SSR, SSE;
Matrix X = J_Mat(Y.row(),1);
X.append_column(X2);
X.print(0);
Part_SS_X_full(Y,X,SST,SSR,SSE);
SSR.print(2);
SSE.print(2);
SST.print(2);
X.append_column(D);
X.print(0);
Part_SS_X_full(Y,X,SST,SSR,SSE);
cout << "full Model SS = " << endl;
SSR.print(2);
SSE.print(2);
SST.print(2);
double F = (13.28/2)/(27.99/11);
cout << "F = " << F << endl;
double P_value = F_r_tailed_prob(F,2,11);
cout.precision(4);
cout << " P_value = " << P_value << endl;
Partial_F_test(Y,X,2,3);
Partial_F_test(Y,X,1,1);
Matrix B = (X.T()*X).inv()*X.T()*Y;
B.print(4);
Partial_t_test(Y,X);
// $$$$$$$ End of your program $$$$$$$$$$$$$$$$$$$$$$$$$
cin.get();
return 0;
}
=====================================复制结束==================================
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.136.161.81
※ 编辑: weiching0323 来自: 140.136.161.81 (06/08 15:26)
※ 编辑: weiching0323 来自: 140.136.161.81 (06/08 15:31)