看板 FJU-STAT95B 關於我們 聯絡資訊
前置作業: 請先看前篇文 這篇直接進入正題. ===================================從以下開始複製============================= #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
abidog:專業的程式設計訓練 04/27 15:54
※ 編輯: weiching0323 來自: 140.136.161.81 (04/27 16:14)
ko7751:泰明哥都來了你還沒畫圖!! 04/27 16:16
※ 編輯: weiching0323 來自: 140.136.161.81 (04/27 16:29)