Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8837 closed Bugs (fixed)

boost::math::students_t quantile() fails for huge degrees of freedom

Reported by: Paul McClellan <paulm@…> Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.54.0 Severity: Problem
Keywords: math Cc:


Student's t quantile function calls policies::raise_rounding_error() in iround() when degrees of freedom = 4503599627370496.

boost::math::students_t students(4503599627370496); double dRes = quantile(students, 0.4);

If this is disabled using #define BOOST_MATH_ROUNDING_ERROR_POLICY ignore_error in user.hpp the computation will continue.

The function inverse_students_t_hill() uses the test ndf > 1e20 to use the Standard Normal approximation, but Boost subsequently attempts to refine the estimate using the Halley step in fast_students_t_quantile_imp() and this becomes unreliable and eventually fails for huge dof such as dof = DBL_MAX (results in completely wrong result) or +Infinity (returns a NaN).

For consistency, I suggest the quantile function us the same threshold as pdf() and cdf() to approximate the Student's t with the standard normal distribution when dof > 1/eps.

I will attempt to attach my user.hpp file.

Attachments (1)

user.hpp (2.8 KB) - added by Paul McClellan <paulm@…> 4 years ago.
user.hpp file for policies

Download all attachments as: .zip

Change History (3)

Changed 4 years ago by Paul McClellan <paulm@…>

Attachment: user.hpp added

user.hpp file for policies

comment:1 Changed 4 years ago by John Maddock

Resolution: fixed
Status: newclosed

(In [85075]) Don't throw exceptions from itrunc/iround if all we're doing is checking to see if the argument is an integer. Don't propagate no-throw policies inside MPFR's itrunc/iround. Use normal approximation to student's t quantile when the degrees of freedom is big enough. Fixes #8837.

comment:2 Changed 4 years ago by John Maddock

(In [85987]) Merge accumulated patches from Trunk. Refs #8384, Refs #8855, refs #9107, refs #9109, refs #8333, refs #8621, refs #8732, refs #8733, refs #8837, refs #8940, refs #9042, refs #9087, refs #9104, refs #9126.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.