| 298 | namespace { |
| 299 | |
| 300 | inline |
| 301 | AnyType |
| 302 | tStatsToResult(double inT, double inDegreeOfFreedom) { |
| 303 | // Return t statistic, degrees of freedom, one-tailed p-value (Null |
| 304 | // hypothesis \mu <= \mu_0), and two-tailed p-value (\mu = \mu_0). |
| 305 | // Recall definition of p-value: The probability of observating a |
| 306 | // value at least as extreme as the one observed, assuming that the null |
| 307 | // hypothesis is true. |
| 308 | using boost::math::complement; |
| 309 | |
| 310 | AnyType tuple; |
| 311 | tuple |
| 312 | << inT |
| 313 | << inDegreeOfFreedom |
| 314 | << prob::cdf(complement(prob::students_t(inDegreeOfFreedom), inT)) |
| 315 | << 2. * prob::cdf(boost::math::complement( |
| 316 | prob::students_t(inDegreeOfFreedom), std::fabs(inT))); |
| 317 | return tuple; |
| 318 | } |
| 319 | |
| 320 | } |
| 321 | |