📄 dcdflib_prb.c
字号:
# include <cstdlib># include <iostream># include <iomanip># include <cmath># include <ctime>using namespace std;# include "dcdflib.H"int main ( void );void test01 ( void );void test02 ( void );void test03 ( void );void test04 ( void );void test05 ( void );void test06 ( void );void test07 ( void );void test08 ( void );void test09 ( void );void test10 ( void );void test11 ( void );void test12 ( void );void test13 ( void );void test14 ( void );void test15 ( void );void test16 ( void );void test17 ( void );void test18 ( void );void test19 ( void );void test20 ( void );void test21 ( void );void test22 ( void );void test23 ( void );void test24 ( void );void test25 ( void );void test26 ( void );void test27 ( void );//****************************************************************************80int main ( void )//****************************************************************************80//// Purpose://// MAIN is the main program for DCDFLIB_PRB.//// Discussion://// DCDFLIB_PRB calls the DCDFLIB tests.//// Modified://// 17 February 2007//// Author://// John Burkardt//{ timestamp ( ); cout << "\n"; cout << "DCDFLIB_PRB\n"; cout << " C++ version\n"; cout << " Test the routines in the DCDFLIB library.\n"; test01 ( ); test02 ( ); test03 ( ); test04 ( ); test05 ( ); test06 ( ); test07 ( ); test08 ( ); test09 ( ); test10 ( ); test11 ( ); test12 ( ); test13 ( ); test14 ( ); test15 ( ); test16 ( ); test17 ( ); test18 ( ); test19 ( ); test20 ( ); test21 ( ); test22 ( ); test23 ( ); test24 ( ); test25 ( ); test26 ( ); test27 ( ); cout << "\n"; cout << "DCDFLIB_PRB\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0;}//****************************************************************************80void test01 ( void )//****************************************************************************80//// Purpose://// TEST01 tests CDFBET.//{ double a; double b; double bound; double p; double q; int status; int which; double x; double y; cout << "\n"; cout << "TEST01\n"; cout << " CDFBET computes one missing parameter from the\n"; cout << " BETA CDF:\n"; cout << "\n"; cout << " BETA_CDF ( (P,Q), (X,Y), A, B )\n"; cout << "\n"; cout << " P Q X Y" << " A B\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; x = 0.25; y = 1.0 - x; a = 2.0; b = 3.0; } else if ( which == 2 ) { p = 0.261719; q = 1.0 - p; x = -1.0; y = -1.0; a = 2.0; b = 3.0; } else if ( which == 3 ) { p = 0.261719; q = 1.0 - p; x = 0.25; y = 1.0 - x; a = -1.0; b = 3.0; } else if ( which == 4 ) { p = 0.261719; q = 1.0 - p; x = 0.25; y = 1.0 - x; a = 2.0; b = -1.0; } cdfbet ( &which, &p, &q, &x, &y, &a, &b, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFBET returned STATUS = " << status << "\n"; continue; } cout << " " << setw(10) << p << " " << setw(10) << q << " " << setw(10) << x << " " << setw(10) << y << " " << setw(10) << a << " " << setw(10) << b << "\n"; } return;}//****************************************************************************80void test02 ( void )//****************************************************************************80//// Purpose://// TEST02 tests CDFBIN.//{ double bound; double ompr; double p; double pr; double q; double s; int status; int which; double xn; cout << "\n"; cout << "TEST02\n"; cout << " CDFBIN computes one missing parameter from the\n"; cout << " Binomial CDF:\n"; cout << "\n"; cout << " BINOMIAL_CDF ( (P,Q), S, XN, (PR,OMPR) )\n"; cout << "\n"; cout << " P Q S " << "XN PR OMPR\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; s = 5.0; xn = 8.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 2 ) { p = 0.067347; q = 1.0 - p; s = -1.0; xn = 8.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 3 ) { p = 0.067347; q = 1.0 - p; s = 5.0; xn = -1.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 4 ) { p = 0.067347; q = 1.0 - p; s = 5.0; xn = 8.0; pr = -1.0; ompr = -1.0; } cdfbin ( &which, &p, &q, &s, &xn, &pr, &ompr, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFBIN returned STATUS = " << status << "\n"; continue; } cout << " " << setw(10) << p << " " << setw(10) << q << " " << setw(10) << s << " " << setw(10) << xn << " " << setw(10) << pr << " " << setw(10) << ompr << "\n"; } return;}//****************************************************************************80void test03 ( void )//****************************************************************************80//// Purpose://// TEST03 tests CDFCHI.//{ double bound; double df; double p; double q; int status; int which; double x; cout << "\n"; cout << "TEST03\n"; cout << " CDFCHI computes one missing parameter from the\n"; cout << " Chi Square CDF:\n"; cout << "\n"; cout << " CHI_CDF ( (P,Q), X, DF )\n"; cout << "\n"; cout << " P Q X DF\n"; cout << "\n"; for ( which = 1; which <= 3; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; x = 5.0; df = 8.0; } else if ( which == 2 ) { p = 0.242424; q = 1.0 - p; x = -1.0; df = 8.0; } else if ( which == 3 ) { p = 0.242424; q = 1.0 - p; x = 5.0; df = -1.0; } cdfchi ( &which, &p, &q, &x, &df, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFCHI returned STATUS = " << status << "\n"; continue; } cout << " " << setw(10) << p << " " << setw(10) << q << " " << setw(10) << x << " " << setw(10) << df << "\n"; } return;}//****************************************************************************80void test04 ( void )//****************************************************************************80//// Purpose://// TEST04 tests CDFCHN.//{ double bound; double df; double p; double pnonc; double q; int status; int which; double x; cout << "\n"; cout << "TEST04\n"; cout << " CDFCHN computes one missing parameter from the\n"; cout << " Chi Square CDF:\n"; cout << "\n"; cout << " CHI_Noncentral_CDF ( (P,Q), X, DF, PNONC )\n"; cout << "\n"; cout << " P Q X DF PNONC\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; x = 5.0; df = 8.0; pnonc = 0.5; } else if ( which == 2 ) { p = 0.211040; q = 1.0 - p; x = -1.0; df = 8.0; pnonc = 0.5; } else if ( which == 3 ) { p = 0.211040; q = 1.0 - p; x = 5.0; df = -1.0; pnonc = 0.5; } else if ( which == 4 ) { p = 0.211040; q = 1.0 - p; x = 5.0; df = 8.0; pnonc = -1.0; } cdfchn ( &which, &p, &q, &x, &df, &pnonc, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFCHN returned STATUS = " << status << "\n"; continue; } cout << " " << setw(8) << p << " " << setw(8) << q << " " << setw(8) << x << " " << setw(8) << df << " " << setw(8) << pnonc << "\n"; } return;}//****************************************************************************80void test05 ( void )//****************************************************************************80//// Purpose://// TEST05 tests CDFF.//{ double bound; double dfd; double dfn; double f; double p; double q; int status; int which; cout << "\n"; cout << "TEST05\n"; cout << " CDFF computes one missing parameter from the\n"; cout << " F CDF:\n"; cout << "\n"; cout << " F_CDF ( (P,Q), F, DFN, DFD )\n"; cout << "\n"; cout << " P Q F DFN DFD\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; f = 5.0; dfn = 8.0; dfd = 3.0; } else if ( which == 2 ) { p = 0.893510; q = 1.0 - p; f = -1.0; dfn = 8.0; dfd = 3.0; } else if ( which == 3 ) { p = 0.893510; q = 1.0 - p; f = 5.0; dfn = -1.0; dfd = 3.0; } else if ( which == 4 ) { p = 0.893510; q = 1.0 - p; f = 5.0; dfn = 8.0; dfd = -1.0; } cdff ( &which, &p, &q, &f, &dfn, &dfd, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFF returned STATUS = " << status << "\n"; continue; } cout << " " << setw(8) << p << " " << setw(8) << q << " " << setw(8) << f << " " << setw(8) << dfn << " " << setw(8) << dfd << "\n"; } return;}//****************************************************************************80void test06 ( void )//****************************************************************************80//// Purpose://// TEST06 tests CDFFNC.//{ double bound; double dfd; double dfn; double f; double p; double pnonc; double q; int status; int which; cout << "\n"; cout << "TEST06\n"; cout << " CDFFNC computes one missing parameter from the\n"; cout << " noncentral F CDF:\n"; cout << "\n"; cout << " F_noncentral_CDF ( (P,Q), F, DFN, DFD, PNONC )\n"; cout << "\n"; cout << " P Q F DFN DFD PNONC\n"; cout << "\n"; for ( which = 1; which <= 5; which++ ) { if ( which == 1 ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -