Modify

Ticket #6934 (closed Bugs: fixed)

Opened 2 years ago

Last modified 21 months ago

quantile() on an inverse_gaussian_distribution<RealType, Policy> object does not compile

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

Description

quantile() creates an object of type inverse_gaussian_quantile_functor<RealType>, the constructor of which expects an argument of type inverse_gaussian_distribution<RealType, policies::policy<> >. Therefore, quantile() cannot be used with a custom policy, because inverse_gaussian_distribution<RealType, Policy> cannot usually be cast to inverse_gaussian_distribution<RealType, policies::policy<> >.

Example:

#include <boost/math/distributions/inverse_gaussian.hpp>

using namespace boost::math;
using namespace boost::math::policies;

typedef policy<
    domain_error<errno_on_error>
> my_policy;

int main() {
    quantile(inverse_gaussian_distribution<double, my_policy>(), .5);
}

Attachments

Change History

comment:1 Changed 2 years ago by johnmaddock

  • Cc pbristow@… added
  • Status changed from new to assigned

Confirmed.

Not sure how this slipped through our concept checks.... will investigate.

Paul did you write this one? If so can I let you fix?

comment:2 Changed 2 years ago by johnmaddock

The following patch updates our tests to show the error:

Index: distribution_concept_check.cpp
===================================================================
--- distribution_concept_check.cpp	(revision 78472)
+++ distribution_concept_check.cpp	(working copy)
@@ -16,26 +16,28 @@
    using namespace boost::math;
    using namespace boost::math::concepts;
 
-   function_requires<DistributionConcept<normal_distribution<RealType> > >();
-   function_requires<DistributionConcept<beta_distribution<RealType> > >();
-   function_requires<DistributionConcept<binomial_distribution<RealType> > >();
-   function_requires<DistributionConcept<cauchy_distribution<RealType> > >();
-   function_requires<DistributionConcept<bernoulli_distribution<RealType> > >();
-   function_requires<DistributionConcept<chi_squared_distribution<RealType> > >();
-   function_requires<DistributionConcept<exponential_distribution<RealType> > >();
-   function_requires<DistributionConcept<extreme_value_distribution<RealType> > >();
-   function_requires<DistributionConcept<fisher_f_distribution<RealType> > >();
-   function_requires<DistributionConcept<gamma_distribution<RealType> > >();
-   function_requires<DistributionConcept<students_t_distribution<RealType> > >();
-   function_requires<DistributionConcept<pareto_distribution<RealType> > >();
-   function_requires<DistributionConcept<poisson_distribution<RealType> > >();
-   function_requires<DistributionConcept<rayleigh_distribution<RealType> > >();
-   function_requires<DistributionConcept<weibull_distribution<RealType> > >();
-   function_requires<DistributionConcept<lognormal_distribution<RealType> > >();
-   function_requires<DistributionConcept<triangular_distribution<RealType> > >();
-   function_requires<DistributionConcept<uniform_distribution<RealType> > >();
-   function_requires<DistributionConcept<negative_binomial_distribution<RealType> > >();
-   function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType> > >();
+   typedef policies::policy<policies::digits2<std::numeric_limits<RealType>::digits - 2> > custom_policy;
+
+   function_requires<DistributionConcept<normal_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<beta_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<binomial_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<cauchy_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<bernoulli_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<chi_squared_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<exponential_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<extreme_value_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<fisher_f_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<gamma_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<students_t_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<pareto_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<poisson_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<rayleigh_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<weibull_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<lognormal_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<triangular_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<uniform_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<negative_binomial_distribution<RealType, custom_policy> > >();
+   function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType, custom_policy> > >();
 }
 
 
Index: instantiate.hpp
===================================================================
--- instantiate.hpp	(revision 78527)
+++ instantiate.hpp	(working copy)
@@ -18,7 +18,7 @@
 
 #ifndef BOOST_MATH_INSTANTIATE_MINIMUM
 
-typedef boost::math::policies::policy<> test_policy;
+typedef boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false> > test_policy;
 
 namespace test{
 

Then try and compile either std_real_concept_check.cpp or test_instantiate1.cpp. Thankfully the inverse_gaussian distro is the only thing that fails.

I haven't committed the above patch, because it'll break the regression tests at present.

John.

comment:3 Changed 2 years ago by pbristow

Thanks for this report. Added template parameter Policy to two functors and test program provided now compiles and runs.

Command: Commit Modified: I:\boost-trunk\boost\math\distributions\inverse_gaussian.hpp Sending content: I:\boost-trunk\boost\math\distributions\inverse_gaussian.hpp Completed: At revision: 78579

(This might not make 1.50 because John Maddock is away. Sorry :-(.

(Also need commit of patch above to confirm meets the full cncept check).

comment:4 Changed 2 years ago by pbristow

  • Status changed from assigned to closed
  • Version changed from Boost 1.49.0 to Boost 1.50.0
  • Resolution set to fixed
  • Milestone changed from To Be Determined to Boost 1.50.0

comment:5 Changed 23 months ago by johnmaddock

(In [78711]) Update concept checks to unmask issues reported in #6934. Add some distributions to the concept tests that were missing before. Add skew_normal_distribution to distributions.hpp. Fix some errors in calculating custom policies when the defaults have been changed. Fix the errors and warnings that result from the above. Refs #6934.

comment:6 Changed 23 months ago by johnmaddock

(In [78771]) Update to use new out-of-bounds error checking. Refs #6934.

comment:7 Changed 23 months ago by johnmaddock

(In [78773]) Add extra error tests for negative_binomial to laplace distros. Refs #6934.

comment:8 Changed 23 months ago by johnmaddock

(In [78778]) Update more distribution tests, from Inverse* down to gamma. Refs #6934.

comment:9 Changed 23 months ago by johnmaddock

(In [78783]) Update more distribution tests for fisher_f and extreme_value and fix failures. Refs #6934.

comment:10 Changed 23 months ago by johnmaddock

(In [78784]) Enhance exponential_distribution tests. Refs #6934.

comment:11 Changed 21 months ago by johnmaddock

  • Milestone changed from Boost 1.50.0 to Boost 1.52.0
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
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.