| Home | Libraries | People | FAQ | More

### Policies Have Sensible Defaults

Most of the time you can just ignore the policy framework.

*The defaults for the various policies are as follows, if these work OK for you then you can stop reading now!

Domain Error

  Throws a `std::domain_error` exception.

Pole Error

  Occurs when a function is evaluated at a pole: throws a `std::domain_error` exception.

Overflow Error

  Throws a `std::overflow_error` exception.

Underflow

  Ignores the underflow, and returns zero.

Denormalised Result

  Ignores the fact that the result is denormalised, and returns it.

Rounding Error

  Throws a `boost::math::rounding_error` exception.

Internal Evaluation Error

  Throws a `boost::math::evaluation_error` exception.

Indeterminate Result Error

  Returns a result that depends on the function where the error occurred.

Promotion of float to double

  Does occur by default - gives full float precision results.

Promotion of double to long double

  Does occur by default if long double offers more precision than double.

Precision of Approximation Used

  By default uses an approximation that will result in the lowest level of error for the type of the result.

Behaviour of Discrete Quantiles

  The quantile function will by default return an integer result that has been rounded outwards. That is to say lower quantiles (where the probability is less than 0.5) are rounded downward, and upper quantiles (where the probability is greater than 0.5) are rounded upwards. This behaviour ensures that if an X% quantile is requested, then at least the requested coverage will be present in the central region, and no more than the requested coverage will be present in the tails.

  This behaviour can be changed so that the quantile functions are rounded differently, or even return a real-valued result using Policies. It is strongly recommended that you read the tutorial Understanding Quantiles of Discrete Distributions before using the quantile function on a discrete distribution. The reference docs describe how to change the rounding policy for these distributions.

What's more, if you define your own policy type, then it automatically inherits the defaults for any policies not explicitly set, so given:

    using namespace boost::math::policies;
    //
    // Define a policy that sets ::errno on overflow, and does
    // not promote double to long double internally:
    //
    typedef policy<domain_error<errno_on_error>, promote_double<false> > mypolicy;

then `mypolicy` defines a policy where only the overflow error handling and `double`-promotion policies differ from the defaults.