Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#6937 closed Bugs (fixed)

Wrong cdf/pdf/quantile domain checks for some probability distributions

Reported by: Florian Schoppmann <Florian.Schoppmann@…> Owned by: johnmaddock
Milestone: Boost 1.52.0 Component: math
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc: pbristow@…

Description

students_t_distribution and fisher_f_distribution are affected, and possibly others (have not checked yet).

quantile(const students_t[...]) contains the following code:

   if(false == detail::check_df(
      function, degrees_of_freedom, &error_result, Policy())
         && detail::check_probability(function, probability, &error_result, Policy()))
      return error_result;

quantile(const fisher_f[...]) contains:

   if(false == detail::check_df(
            function, df1, &error_result, Policy())
         && detail::check_df(
            function, df2, &error_result, Policy())
         && detail::check_probability(
            function, p, &error_result, Policy()))
      return error_result;

The code snippets above would only be correct if the "&&" operator had precedence over "==". pdf and cdf contain code of the same form.

Side effects:

  • The Student's t quantile() can be called with a probability outside of [0,1] with unexpected results. Example:
    #include <boost/math/distributions/students_t.hpp>
    using namespace boost::math;
    int main() {
        std::cout << quantile(students_t(1), 2) << std::endl;
    }
    

The output is: -1.84467e+19

  • The Fisher F quantile() function, when called with probability NaN and parameters 1 and 1, leads to a failed BOOST_ASSERT. Example:
    #include <boost/math/distributions/fisher_f.hpp>
    using namespace boost::math;
    int main() {
        quantile(fisher_f(1, 1), std::numeric_limits<double>::quiet_NaN());
    }
    

Attachments (0)

Change History (5)

comment:1 Changed 5 years ago by johnmaddock

  • Cc pbristow@… added
  • Milestone changed from To Be Determined to Boost 1.51.0
  • Status changed from new to assigned

comment:2 Changed 5 years ago by johnmaddock

Oh dear!

This looks to be a systematic error through all the distributions.

Paul - looks like we need to:

  • Check all the distributions.
  • Add tests for all possible domain errors (including those pesky NaN's - when std::numeric_limits<T>::has_quiet_NaN is true) for all the distros.

comment:3 Changed 5 years ago by johnmaddock

(In [78726]) Improve testing of error conditions and fix any errors detected. Takes care of distributions normal-weibull. Refs #6937.

comment:4 Changed 5 years ago by johnmaddock

  • Resolution set to fixed
  • Status changed from assigned to closed

I believe this is now fixed in Trunk.

comment:5 Changed 5 years ago by johnmaddock

  • Milestone changed from Boost 1.51.0 to Boost 1.52.0

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain johnmaddock.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.