【问题标题】:boost discrete uniform distribution提升离散均匀分布
【发布时间】:2018-02-07 00:54:48
【问题描述】:

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

以下返回一个介于 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); 

是否完全应用了该政策?

【问题讨论】:

  • sehe 的回答表明没有离散的均匀分布。但是,如果您在积分限制之间具有连续均匀分布,则从连续分布中采样 x 的 floor(x) 在从下限到更大负 1 的整数上具有均匀离散分布。

标签: c++ boost statistics uniform-distribution


【解决方案1】:

出于多态原因,我使用uniform_distribution 而不是uniform_int_distribution

数学库没有uniform_int_distribution,这是一个奇怪的声明。

以下返回一个介于 10 和 20 之间的浮点值,而不是整数值:

该分布是连续分布。 The docs 只是短暂地参考维基百科说“还有一个离散的均匀分布。”但他们没有明确说明是否实现了这样的事情。

查看源代码表明该策略没有被使用:

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

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

【讨论】:

    猜你喜欢
    • 2011-08-07
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 2019-02-22
    • 2021-11-23
    • 2011-04-04
    • 2011-09-16
    • 1970-01-01
    相关资源
    最近更新 更多