Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6934 closed Bugs (fixed)

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

Reported by: Florian Schoppmann <Florian.Schoppmann@…> Owned by: John Maddock
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);
}

Change History (11)

comment:1 by John Maddock, 10 years ago

Cc: pbristow@… added
Status: newassigned

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 by John Maddock, 10 years ago

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 by Paul A. Bristow, 10 years ago

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 by Paul A. Bristow, 10 years ago

Milestone: To Be DeterminedBoost 1.50.0
Resolution: fixed
Status: assignedclosed
Version: Boost 1.49.0Boost 1.50.0

comment:5 by John Maddock, 10 years ago

(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 by John Maddock, 10 years ago

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

comment:7 by John Maddock, 10 years ago

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

comment:8 by John Maddock, 10 years ago

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

comment:9 by John Maddock, 10 years ago

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

comment:10 by John Maddock, 10 years ago

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

comment:11 by John Maddock, 10 years ago

Milestone: Boost 1.50.0Boost 1.52.0
Note: See TracTickets for help on using tickets.