For $df=1$ and $t<7.45e-9$, the student t distribution CDF simply computes 0.5, a constant value.
Reproducer:
#include <boost/math/distributions/students_t.hpp>
#include <boost/math/constants/constants.hpp>
#include <iostream>
#include <cmath>
int main() {
for (double t : {1e-20, 1e-15, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1}) {
double p = boost::math::cdf(boost::math::students_t_distribution<double>(1.), t);
double p_simple = 0.5 + std::atan2(t, 1.0) / M_PI;
std::cout << "t: " << t << ", p: " << p << ", p simple: " << p_simple << std::endl;
}
return 0;
}
This prints out:
t: 1e-20, p: 0.5, p simple: 0.5
t: 1e-15, p: 0.5, p simple: 0.5
t: 1e-10, p: 0.5, p simple: 0.5
t: 1e-09, p: 0.5, p simple: 0.5
t: 1e-08, p: 0.5, p simple: 0.5
t: 1e-07, p: 0.5, p simple: 0.5
t: 1e-06, p: 0.5, p simple: 0.5
t: 1e-05, p: 0.500003, p simple: 0.500003
t: 0.0001, p: 0.500032, p simple: 0.500032
t: 0.001, p: 0.500318, p simple: 0.500318
t: 0.01, p: 0.503183, p simple: 0.503183
t: 0.1, p: 0.531726, p simple: 0.531726
This came up in scipy/scipy#25667. The issue also contains a root cause analysis by Claude Fable. Interestingly, using the naive formula I get a good result using the Python standard library: 0.5 + math.atan(1e-10)/math.pi yields 0.500000000031831.
For$df=1$ and $t<7.45e-9$ , the student t distribution CDF simply computes 0.5, a constant value.
Reproducer:
This prints out:
This came up in scipy/scipy#25667. The issue also contains a root cause analysis by Claude Fable. Interestingly, using the naive formula I get a good result using the Python standard library:
0.5 + math.atan(1e-10)/math.piyields0.500000000031831.