I have a variety of distributions from which I draw samples, pdf and cdf. For polymorphic reasons I am using a uniform_distribution instead of uniform_int_distribution.
The following returns me a floating value between 10 and 20 instead of integral values:
typedef uniform_distribution<double,
policy<discrete_quantile<integer_round_outwards>>> uniform_round_outwards;
uniform_round_outwards _uniformObject(10,20);
x = quantile(_uniformObject, p);
Is the policy being applied at all?
For polymorphic reasons I am using a
uniform_distribution
instead ofuniform_int_distribution
.
The Math library doesn't have a uniform_int_distribution
, making that a weird statement.
The following returns me a floating value between 10 and 20 instead of integral values:
That distribution is a continuous distribution. The docs only fleetingly refer to Wikipedia to say "There is also a discrete uniform distribution.", but they fail to explicitly state whether or not such a thing is implemented.
Looking at the source shows that the policy is not being used:
template <class RealType, class Policy>
inline RealType quantile(const uniform_distribution<RealType, Policy>& dist, const RealType& p)
{
RealType lower = dist.lower();
RealType upper = dist.upper();
RealType result = 0; // of checks
if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy()))
{
return result;
}
if(false == detail::check_probability("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", p, &result, Policy()))
{
return result;
}
if(p == 0)
{
return lower;
}
if(p == 1)
{
return upper;
}
return p * (upper - lower) + lower;
}
My conclusion is that the discrete uniform distribution is not implemented in this class.