id summary reporter owner description type status milestone component version severity resolution keywords cc 11557 cdf error with non-central chi-squared with ncp = 0 Mark Abney John Maddock "The complement of the cdf of the non-central chi-squared distribution with non-centrality parameter = 0 should return the same value as the standard (i.e. central) chi-squared distribution. For ncp very small, this happens, but when ncp = 0 it returns the negative of the (non-complement) cdf. Example code: {{{ #include #include using std::cout; using std::cin; using std::endl; using boost::math::chi_squared; int main(int argc, char *argv[]) { double df = 4, quantile = 12; cout << ""df = "" << df << endl; cout << ""quantile = "" << quantile << endl; chi_squared chi(df); cout << ""chi.df = "" << chi.degrees_of_freedom() << endl; cout << ""P(X <= "" << quantile << "") = "" << cdf(chi, quantile) << endl; cout << ""P(X > "" << quantile << "") = "" << cdf(complement(chi, quantile)) << endl; double ncp1 = 1e-300; double ncp2 = 0; boost::math::non_central_chi_squared nchi1(df, ncp1); boost::math::non_central_chi_squared nchi2(df, ncp2); cout << ""nchi1.df = "" << nchi1.degrees_of_freedom() << ""; nchi1.ncp = "" << nchi1.non_centrality() << endl; cout << ""P(X <= "" << quantile << "") = "" << cdf(nchi1, quantile) << endl; cout << ""P(X > "" << quantile << "") = "" << cdf(complement(nchi1, quantile)) << endl; cout << ""nchi2.df = "" << nchi2.degrees_of_freedom() << ""; nchi2.ncp = "" << nchi2.non_centrality() << endl; cout << ""P(X <= "" << quantile << "") = "" << cdf(nchi2, quantile) << endl; cout << ""P(X > "" << quantile << "") = "" << cdf(complement(nchi2, quantile)) << endl; return 0; } }}} Note the output lines P(X > 12), which should all be equal. In the first two cases this is correct, but in the last one P(X > 12) = - P(X <= 12), which is necessarily wrong." Bugs closed Boost 1.60.0 math Boost 1.59.0 Problem fixed