提升离散均匀分布

boost discrete uniform distribution

我有各种各样的分布,我从中抽取样本,pdf 和 cdf。出于多态的原因,我使用 uniform_distribution 而不是 uniform_int_distribution。

以下returns我是10到20之间的浮点值而不是整数值:

 typedef uniform_distribution<double,
                policy<discrete_quantile<integer_round_outwards>>> uniform_round_outwards;

 uniform_round_outwards  _uniformObject(10,20);

 x = quantile(_uniformObject, p); 

政策是否得到应用?

For polymorphic reasons I am using a uniform_distribution instead of uniform_int_distribution.

数学库没有 uniform_int_distribution,这是一个奇怪的说法。

The following returns me a floating value between 10 and 20 instead of integral values:

该分布是连续分布。 The docs 只是短暂地参考维基百科说 "There is also a discrete uniform distribution.",但他们没有明确说明是否实施了这样的事情。

查看源代码显示该策略未被使用:

  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;
  }

我的结论是这个class没有实现离散均匀分布。