...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
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!
Occurs when a function is evaluated at a pole: throws a
Ignores the underflow, and returns zero.
Ignores the fact that the result is denormalised, and returns it.
Returns a result that depends on the function where the error occurred.
Does occur by default - gives full float precision results.
Does occur by default if long double offers more precision than double.
By default uses an approximation that will result in the lowest level of error for the type of the result.
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> > my_policy;
my_policy defines a
policy where only the overflow error handling and
policies differ from the defaults.
We can also add a desired precision, for example, 9 bits or 3 decimal digits, to an error-handling policy, usually to trade precision for speed:
typedef policy<domain_error<errno_on_error>, digit2<9> > my_policy;
Or if you want to further modify an existing user policy, use
using boost::math::policies::normalise; typedef normalise<my_policy, digits2<9>>::type my_policy_9; // errno on error, and limited precision.