📄 dcdflib_prb.c
字号:
p = -1.0; q = -1.0; f = 5.0; dfn = 8.0; dfd = 3.0; pnonc = 17.648016; } else if ( which == 2 ) { p = 0.60; q = 1.0 - p; f = -1.0; dfn = 8.0; dfd = 3.0; pnonc = 17.648016; } else if ( which == 3 ) { p = 0.60; q = 1.0 - p; f = 5.0; dfn = -1.0; dfd = 3.0; pnonc = 17.648016; } else if ( which == 4 ) { p = 0.60; q = 1.0 - p; f = 5.0; dfn = 8.0; dfd = -1.0; pnonc = 17.648016; } else if ( which == 5 ) { p = 0.60; q = 1.0 - p; f = 5.0; dfn = 8.0; dfd = 3.0; pnonc = -1.0; } cdffnc ( &which, &p, &q, &f, &dfn, &dfd, &pnonc, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFFNC returned STATUS = " << status << "\n"; continue; } cout << " " << setw(8) << p << " " << setw(8) << q << " " << setw(8) << f << " " << setw(8) << dfn << " " << setw(8) << dfd << " " << setw(8) << pnonc << "\n"; } return;}//****************************************************************************80void test07 ( void )//****************************************************************************80//// Purpose://// TEST07 tests CDFGAM.//{ double bound; double p; double q; double scale; double shape; int status; int which; double x; cout << "\n"; cout << "TEST07\n"; cout << " CDFGAM computes one missing parameter from the\n"; cout << " Gamma CDF:\n"; cout << "\n"; cout << " Gamma_CDF ( (P,Q), X, SHAPE, SCALE )\n"; cout << "\n"; cout << " P Q X SHAPE SCALE\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; x = 5.0; shape = 8.0; scale = 3.0; } else if ( which == 2 ) { p = 0.981998; q = 1.0 - p; x = -1.0; shape = 8.0; scale = 3.0; } else if ( which == 3 ) { p = 0.981998; q = 1.0 - p; x = 5.0; shape = -1.0; scale = 3.0; } else if ( which == 4 ) { p = 0.981998; q = 1.0 - p; x = 5.0; shape = 8.0; scale = -1.0; } cdfgam ( &which, &p, &q, &x, &shape, &scale, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFGAM returned STATUS = " << status << "\n"; continue; } cout << " " << setw(8) << p << " " << setw(9) << q << " " << setw(8) << x << " " << setw(8) << shape << " " << setw(8) << scale << "\n"; } return;}//****************************************************************************80void test08 ( void )//****************************************************************************80//// Purpose://// TEST08 tests CDFNBN.//{ double bound; double f; double ompr; double p; double pr; double q; double s; int status; int which; cout << "\n"; cout << "TEST08\n"; cout << " CDFNBN computes one missing parameter from the\n"; cout << " Negative_Binomial CDF:\n"; cout << "\n"; cout << " Negative_BINOMIAL_CDF ( (P,Q), F, S, (PR,OMPR) )\n"; cout << "\n"; cout << " P Q F S PR OMPR\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; f = 3.0; s = 5.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 2 ) { p = 0.988752; q = 1.0 - p; f = -1.0; s = 5.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 3 ) { p = 0.988752; q = 1.0 - p; f = 3.0; s = -1.0; pr = 0.875; ompr = 1.0 - pr; } else if ( which == 4 ) { p = 0.988752; q = 1.0 - p; f = 3.0; s = 5.0; pr = -1.0; ompr = -1.0; } cdfnbn ( &which, &p, &q, &f, &s, &pr, &ompr, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFNBN returned STATUS = " << status << "\n"; continue; } cout << " " << setw(8) << p << " " << setw(9) << q << " " << setw(8) << f << " " << setw(8) << s << " " << setw(8) << pr << " " << setw(8) << ompr << "\n"; } return;}//****************************************************************************80void test09 ( void )//****************************************************************************80//// Purpose://// TEST09 tests CDFNOR.//{ double bound; double mean; double p; double q; double sd; int status; int which; double x; cout << "\n"; cout << "TEST09\n"; cout << " CDFNOR computes one missing parameter from the\n"; cout << " Normal CDF:\n"; cout << "\n"; cout << " Normal_CDF ( (P,Q), X, MEAN, SD )\n"; cout << "\n"; cout << " P Q X MEAN SD\n"; cout << "\n"; for ( which = 1; which <= 4; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; x = 3.0; mean = 5.0; sd = 0.875; } else if ( which == 2 ) { p = 0.011135; q = 1.0 - p; x = -1.0; mean = 5.0; sd = 0.875; } else if ( which == 3 ) { p = 0.011135; q = 1.0 - p; x = 3.0; mean = -1.0; sd = 0.875; } else if ( which == 4 ) { p = 0.011135; q = 1.0 - p; x = 3.0; mean = 5.0; sd = -1.0; } cdfnor ( &which, &p, &q, &x, &mean, &sd, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFNOR returned STATUS = " << status << "\n"; continue; } cout << " " << setw(9) << p << " " << setw(8) << q << " " << setw(8) << x << " " << setw(8) << mean << " " << setw(8) << sd << "\n"; } return;}//****************************************************************************80void test10 ( void )//****************************************************************************80//// Purpose://// TEST10 tests CDFPOI.//{ double bound; double p; double q; double s; int status; int which; double xlam; cout << "\n"; cout << "TEST10\n"; cout << " CDFPOI computes one missing parameter from the\n"; cout << " Poisson CDF:\n"; cout << "\n"; cout << " POISSON_CDF ( (P,Q), S, XLAM )\n"; cout << "\n"; cout << " P Q S XLAM\n"; cout << "\n"; for ( which = 1; which <= 3; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; s = 3.0; xlam = 5.0; } else if ( which == 2 ) { p = 0.265026; q = 1.0 - p; s = -1.0; xlam = 5.0; } else if ( which == 3 ) { p = 0.265026; q = 1.0 - p; s = 3.0; xlam = -1.0; } cdfpoi ( &which, &p, &q, &s, &xlam, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFPOI returned STATUS = " << status << "\n"; continue; } cout << " " << setw(9) << p << " " << setw(9) << q << " " << setw(9) << s << " " << setw(9) << xlam << "\n"; } return;}//****************************************************************************80void test11 ( void )//****************************************************************************80//// Purpose://// TEST11 tests CDFT.//{ double bound; double df; double p; double q; int status; double t; int which; cout << "\n"; cout << "TEST11\n"; cout << " CDFT computes one missing parameter from the\n"; cout << " T CDF:\n"; cout << "\n"; cout << " T_CDF ( (P,Q), T, DF )\n"; cout << "\n"; cout << " P Q T DF\n"; cout << "\n"; for ( which = 1; which <= 3; which++ ) { if ( which == 1 ) { p = -1.0; q = -1.0; t = 3.0; df = 5.0; } else if ( which == 2 ) { p = 0.984950; q = 1.0 - p; t = -1.0; df = 5.0; } else if ( which == 3 ) { p = 0.984950; q = 1.0 - p; t = 3.0; df = -1.0; } cdft ( &which, &p, &q, &t, &df, &status, &bound ); if ( status != 0 ) { cout << "\n"; cout << " CDFT returned STATUS = " << status << "\n"; continue; } cout << " " << setw(9) << p << " " << setw(9) << q << " " << setw(9) << t << " " << setw(9) << df << "\n"; } return;}//****************************************************************************80void test12 ( void )//****************************************************************************80//// Purpose://// TEST12 tests CUMBET, BETA_INC_VALUES.//{ double a; double b; double ccdf_compute; double ccdf_lookup; double cdf_compute; double cdf_lookup; int n_data; double x; double y; cout << "\n"; cout << "TEST12\n"; cout << " CUMBET computes the Beta CDF\n"; cout << " and the complementary CDF.\n"; cout << " BETA_INC_CDF_VALUES looks up some values.\n"; cout << "\n"; cout << " X Y A B CDF CDF\n"; cout << " (Lookup) (Computed)\n"; cout << "\n"; n_data = 0; for ( ; ; ) { beta_inc_values ( &n_data, &a, &b, &x, &cdf_lookup ); if ( n_data == 0 ) { break; } y = 1.0E+00 - x; cumbet ( &x, &y, &a, &b, &cdf_compute, &ccdf_compute ); cout << " " << setw(9) << x << " " << setw(9) << y << " " << setw(9) << a << " " << setw(9) << b << " " << setw(9) << cdf_lookup << " " << setw(9) << cdf_compute << "\n"; } cout << "\n"; cout << " X Y A B 1-CDF CCDF\n"; cout << " (Lookup) (Computed)\n"; cout << "\n"; n_data = 0; for ( ; ; ) { beta_inc_values ( &n_data, &a, &b, &x, &cdf_lookup ); if ( n_data == 0 ) { break; } ccdf_lookup = 1.0E+00 - cdf_lookup; y = 1.0E+00 - x; cumbet ( &x, &y, &a, &b, &cdf_compute, &ccdf_compute ); cout << " " << setw(9) << x << " " << setw(9) << y << " " << setw(9) << a << " " << setw(9) << b << " " << setw(9) << ccdf_lookup << " " << setw(9) << ccdf_compute << "\n"; } return;}//****************************************************************************80void test13 ( void )//****************************************************************************80//// Purpose://// TEST13 tests CUMBIN, BINOMIAL_CDF_VALUES.//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -