作者weiching0323 (许惟妮)
看板FJU-STAT95B
标题[专业] 无母数课堂笔记15:40-16:30
时间Tue Apr 27 15:51:21 2010
前置作业:
请先看前篇文
这篇直接进入正题.
===================================从以下开始复制=============================
#include <C:\devcpp\all.h>
double Chi2_CDF( double x )
{ return X2_CDF( x, 8 );
}
double Chi2_den( double x )
{ return gam_den( x, 8.0/2, 2);
}
int main()
{
long int i, j;
srand((unsigned)time(NULL));
cout.setf(ios::fixed); cout.precision(10);
// $$$$$$$$ Start your program here $$$$$$$$$$$$$$$$$$$$$
Matrix X;
X.read_from_file("C:\\devcpp\\RC.dat",3);
X.print(0);
X.X2_test().print(3);
double X2 = X.X2_test();
cout << "critical value alfa = 0.05" << endl;
cout << root_of(Chi2_CDF, 0.95, 8 ) << endl;
cout << "C.V. alfa = 0.005" << endl;
cout << root_of(Chi2_CDF, 0.995, 8) << endl;
cout << "P_value = " << endl;
cout.precision(10);
cout << 1.0-Chi2_CDF(X2) << endl;
Univar Chi2;
for(i=0; i < 10000; i++)
{ double X2 = X.random_RC().X2_test();\
Chi2.push_back(X2);
}
//Chi2.freq_dist();
cout << "Monte Carlo P_value = " << endl;
cout.precision(6);
cout << 1.0-Chi2.emp_CDF(X2) << endl;
Univar x = time_axis(0,50,1);
multi_dis G(x);
G.push_freq_dist(Chi2.freq_dist());
G.push_function(Chi2_den);
G.print_to_file("c:\\devcpp\\O.dat",4);
// $$$$$$$ End of your program $$$$$$$$$$$$$$$$$$$$$$$$$
================================复制结束======================================
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.136.161.81
1F:推 abidog:专业的程式设计训练 04/27 15:54
※ 编辑: weiching0323 来自: 140.136.161.81 (04/27 16:14)
2F:→ ko7751:泰明哥都来了你还没画图!! 04/27 16:16
※ 编辑: weiching0323 来自: 140.136.161.81 (04/27 16:29)