Boost C++ 库

……是世界上备受推崇和设计精湛的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

类模板 hyperexponential_distribution - Boost C++ 函数库
PrevUpHomeNext

类模板 hyperexponential_distribution

boost::random::hyperexponential_distribution

提要

// In header: <boost/random/hyperexponential_distribution.hpp>

template<typename RealT = double> 
class hyperexponential_distribution {
public:
  // types
  typedef RealT result_type;
  typedef RealT input_type; 

  // member classes/structs/unions

  class param_type {
  public:
    // types
    typedef hyperexponential_distribution distribution_type;

    // public member functions
    param_type();
    template<typename ProbIterT, typename RateIterT> 
      param_type(ProbIterT, ProbIterT, RateIterT, RateIterT);
    template<typename ProbRangeT, typename RateRangeT> 
      param_type(ProbRangeT const &, RateRangeT const &, 
                 typename boost::disable_if_c< boost::has_pre_increment< ProbRangeT >::value||boost::has_pre_increment< RateRangeT >::value >::type * = 0);
    template<typename RateIterT> 
      param_type(RateIterT, RateIterT, 
                 typename boost::enable_if_c< boost::has_pre_increment< RateIterT >::value >::type * = 0);
    template<typename RateRangeT> param_type(RateRangeT const &);
    param_type(std::initializer_list< RealT >, std::initializer_list< RealT >);
    param_type(std::initializer_list< RealT >);
    std::vector< RealT > probabilities() const;
    std::vector< RealT > rates() const;

    // friend functions
    template<typename CharT, typename Traits> 
      std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > &, const param_type &);
    template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > &, const param_type &);
    bool operator==(const param_type &, const param_type &);
    bool operator!=(const param_type &, const param_type &);
  };

  // public member functions
  hyperexponential_distribution();
  template<typename ProbIterT, typename RateIterT> 
    hyperexponential_distribution(ProbIterT, ProbIterT, RateIterT, RateIterT);
  template<typename ProbRangeT, typename RateRangeT> 
    hyperexponential_distribution(ProbRangeT const &, RateRangeT const &, 
                                  typename boost::disable_if_c< boost::has_pre_increment< ProbRangeT >::value||boost::has_pre_increment< RateRangeT >::value >::type * = 0);
  template<typename RateIterT> 
    hyperexponential_distribution(RateIterT, RateIterT, 
                                  typename boost::enable_if_c< boost::has_pre_increment< RateIterT >::value >::type * = 0);
  template<typename RateRangeT> 
    hyperexponential_distribution(RateRangeT const &);
  explicit hyperexponential_distribution(param_type const &);
  hyperexponential_distribution(std::initializer_list< RealT > const &, 
                                std::initializer_list< RealT > const &);
  hyperexponential_distribution(std::initializer_list< RealT > const &);
  template<typename URNG> RealT operator()(URNG &) const;
  template<typename URNG> RealT operator()(URNG &, const param_type &) const;
  std::size_t num_phases() const;
  std::vector< RealT > probabilities() const;
  std::vector< RealT > rates() const;
  RealT min() const;
  RealT max() const;
  param_type param() const;
  void param(param_type const &);
  void reset();

  // friend functions
  template<typename CharT, typename Traits> 
    std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, 
               const hyperexponential_distribution &);
  template<typename CharT, typename Traits> 
    std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               const hyperexponential_distribution &);
  bool operator==(const hyperexponential_distribution &, 
                  const hyperexponential_distribution &);
  bool operator!=(const hyperexponential_distribution &, 
                  const hyperexponential_distribution &);
};

描述

超指数分布是一个实值连续分布,有两个参数:阶段概率向量 `probs` 和 速率向量 `rates`。

一个 -阶段的超指数分布是 个指数分布的混合。因此,它也被称为 混合指数分布并行 -阶段指数分布

一个 -阶段的超指数分布由两个参数表征,即 阶段概率向量 速率向量

一个 -阶段的超指数分布经常用于 排队论 中,用于模拟 个独立事件的叠加的分布,例如,一个具有 个并行服务器的排队站的服务时间分布,其中第 个服务器以概率 被选中,并且其服务时间分布是以速率 的指数分布(Allen,1990; Papadopolous et al.,1993; Trivedi,2002)。

例如,计算系统中的 CPU 服务时间分布经常被观察到具有这种分布(Rosin,1965)。此外,不同类型的客户到达单个排队站通常被建模为超指数分布(Papadopolous et al.,1993)。类似地,如果一个产品在多个并行装配线上生产,并且输出合并,则整个产品的故障密度很可能呈超指数分布(Trivedi,2002)。

最后,由于超指数分布具有很高的变异系数(CoV),即 CoV > 1,因此它特别适用于拟合具有大 CoV 的经验数据(Feitelson,2014; Wolski et al.,2013)以及近似 长尾概率分布(Feldmann et al.,1998)。

有关更多信息和示例,请参阅(Boost,2014)。

一个 -阶段的超指数分布具有概率密度函数

公式 31.1。


其中

  • 阶段数 也是输入向量参数的大小,

  • 阶段概率向量 参数,并且

  • 速率向量 参数。

给定一个具有阶段概率向量 和速率向量 -阶段超指数分布,随机变量生成算法包含以下步骤(Tyszer,1999):

  1. 生成一个在区间 上均匀分布的随机变量

  2. 使用 来选择合适的 (例如,可以使用 别名方法 来完成此步骤)。

  3. 生成一个速率参数为 的指数分布随机变量

  4. 返回

参考文献

  1. A.O. Allen, Probability, Statistics, and Queuing Theory with Computer Science Applications, Second Edition, Academic Press, 1990。

  2. Boost C++ Libraries, Boost.Math / Statistical Distributions: Hyperexponential Distribution, Online: https://boost.ac.cn/doc/libs/release/libs/math/doc/html/dist.html , 2014。

  3. D.G. Feitelson, Workload Modeling for Computer Systems Performance Evaluation, Cambridge University Press, 2014

  4. A. Feldmann and W. Whitt, Fitting mixtures of exponentials to long-tail distributions to analyze network performance models, Performance Evaluation 31(3-4):245, doi:10.1016/S0166-5316(97)00003-5, 1998。

  5. H.T. Papadopolous, C. Heavey and J. Browne, Queueing Theory in Manufacturing Systems Analysis and Design, Chapman & Hall/CRC, 1993, p. 35。

  6. R.F. Rosin, Determining a computing center environment, Communications of the ACM 8(7):463-468, 1965。

  7. K.S. Trivedi, Probability and Statistics with Reliability, Queueing, and Computer Science Applications, John Wiley & Sons, Inc., 2002。

  8. J. Tyszer, Object-Oriented Computer Simulation of Discrete-Event Systems, Springer, 1999。

  9. Wikipedia, Hyperexponential Distribution, Online: http://en.wikipedia.org/wiki/Hyperexponential_distribution , 2014。

  10. Wolfram Mathematica, Hyperexponential Distribution, Online: http://reference.wolfram.com/language/ref/HyperexponentialDistribution.html , 2014。

Marco Guazzone (marco.guazzone@gmail.com)

`hyperexponential_distribution` 公共成员函数

  1. hyperexponential_distribution();

    构造一个具有速率 1 的 1-阶段 `hyperexponential_distribution`(即指数分布)。

  2. template<typename ProbIterT, typename RateIterT> 
      hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last, 
                                    RateIterT rate_first, RateIterT rate_last);

    根据分布的 阶段概率向量速率向量 参数构造一个 `hyperexponential_distribution`。

    阶段概率向量 参数由 [prob_first, prob_last) 迭代器对定义的范围给出,而 速率向量 参数由 [rate_first, rate_last) 迭代器对定义的范围给出。

    参考文献

    1. ISO, ISO/IEC 14882-2014: Information technology - Programming languages - C++, 2014

    参数

    prob_first

    指向表示阶段概率的非负实数元素范围的开始的迭代器;如果元素不求和为 1,则会进行归一化。

    prob_last

    指向表示阶段概率的非负实数范围的结束的迭代器;如果元素不求和为 1,则会进行归一化。

    rate_first

    指向表示速率的非负实数范围的开始的迭代器。

    rate_last

    指向表示速率的非负实数范围的结束的迭代器。

    模板参数

    ProbIterT

    必须满足 `InputIterator` 概念的要求(ISO,2014,sec. 24.2.3 [input.iterators])。

    RateIterT

    必须满足 `InputIterator` 概念的要求(ISO,2014,sec. 24.2.3 [input.iterators])。

  3. template<typename ProbRangeT, typename RateRangeT> 
      hyperexponential_distribution(ProbRangeT const & prob_range, 
                                    RateRangeT const & rate_range, 
                                    typename boost::disable_if_c< boost::has_pre_increment< ProbRangeT >::value||boost::has_pre_increment< RateRangeT >::value >::type * = 0);

    根据分布的 阶段概率向量速率向量 参数构造一个 `hyperexponential_distribution`。

    阶段概率向量 参数由 prob_range 定义的范围给出,而 速率向量 参数由 rate_range 定义的范围给出。

    [Note] 注意

    最后的 `disable_if` 参数是一个实现细节,用于区分此双参数构造函数和下面描述的基于迭代器的双参数构造函数。

    参数

    prob_range

    表示阶段概率的非负实数元素范围;如果元素不求和为 1,则会进行归一化。

    rate_range

    表示速率的正实数元素范围。

    模板参数

    ProbRangeT

    必须满足 `Range` 概念的要求。

    RateRangeT

    必须满足 `Range` 概念的要求。

  4. template<typename RateIterT> 
      hyperexponential_distribution(RateIterT rate_first, RateIterT rate_last, 
                                    typename boost::enable_if_c< boost::has_pre_increment< RateIterT >::value >::type * = 0);

    根据分布的 速率向量 参数构造一个 `hyperexponential_distribution`,并具有相等的阶段概率。

    速率向量参数由 [rate_first, rate_last) 迭代器对定义的范围给出,而阶段概率向量参数被设置为相等的阶段概率(即,一个与速率向量长度 相同的向量,每个元素设置为 )。

    [Note] 注意

    最后的 `disable_if` 参数是一个实现细节,用于区分此双参数构造函数和上面描述的基于范围的双参数构造函数。

    参考文献

    1. ISO, ISO/IEC 14882-2014: Information technology - Programming languages - C++, 2014

    参数

    rate_first

    指向表示速率的非负实数范围的开始的迭代器。

    rate_last

    指向表示速率的非负实数范围的结束的迭代器。

    模板参数

    RateIterT

    必须满足 `InputIterator` 概念的要求(ISO,2014,sec. 24.2.3 [input.iterators])。

  5. template<typename RateRangeT> 
      hyperexponential_distribution(RateRangeT const & rate_range);

    根据分布的“速率”参数构造一个 `param_type`,并具有相等的阶段概率。

    速率向量参数由 rate_range 定义的范围给出,而阶段概率向量参数被设置为相等的阶段概率(即,一个与速率向量长度 相同的向量,每个元素设置为 )。

    参数

    rate_range

    表示速率的正实数元素范围。

    模板参数

    RateRangeT

    必须满足 `Range` 概念的要求。

  6. explicit hyperexponential_distribution(param_type const & param);

    根据其参数构造一个 `hyperexponential_distribution`。

    参数

    param

    分布的参数。

  7. hyperexponential_distribution(std::initializer_list< RealT > const & l1, 
                                  std::initializer_list< RealT > const & l2);

    根据分布的 阶段概率向量速率向量 参数构造一个 `hyperexponential_distribution`。

    阶段概率向量 参数由 l1 定义的 brace-init-list(ISO,2014,sec. 8.5.4 [dcl.init.list])给出,而 速率向量 参数由 l2 定义的 brace-init-list(ISO,2014,sec. 8.5.4 [dcl.init.list])给出。

    参考文献

    1. ISO, ISO/IEC 14882-2014: Information technology - Programming languages - C++, 2014

    参数

    l1

    用于初始化阶段概率向量的初始化列表。

    l2

    用于初始化速率向量的初始化列表。

  8. hyperexponential_distribution(std::initializer_list< RealT > const & l1);

    根据分布的 速率向量 参数构造一个 `hyperexponential_distribution`,并具有相等的阶段概率。

    速率向量 参数由 l1 定义的 brace-init-list(ISO,2014,sec. 8.5.4 [dcl.init.list])给出,而 阶段概率向量 参数被设置为相等的阶段概率(即,一个与速率向量长度 相同的向量,每个元素设置为 )。

    参考文献

    1. ISO, ISO/IEC 14882-2014: Information technology - Programming languages - C++, 2014

    参数

    l1

    用于初始化速率向量的初始化列表。

  9. template<typename URNG> RealT operator()(URNG & urng) const;

    获取按照超指数分布分布的随机变量。

    参数

    urng

    一个均匀随机数生成器对象。

    模板参数

    URNG

    必须满足 `Uniform Random Number Generator` 的要求。

    返回

    按照超指数分布分布的随机变量。

  10. template<typename URNG> 
      RealT operator()(URNG & urng, const param_type & param) const;

    获取按照由 `param` 指定的参数的超指数分布分布的随机变量。

    参数

    urng

    一个均匀随机数生成器对象。

    param

    一个分布参数对象。

    模板参数

    URNG

    必须满足 `Uniform Random Number Generator` 的要求。

    返回

    按照由 `param` 指定的参数的超指数分布分布的随机变量。

  11. std::size_t num_phases() const;

    返回分布的阶段数。

  12. std::vector< RealT > probabilities() const;

    返回分布的 阶段概率向量 参数。

  13. std::vector< RealT > rates() const;

    返回分布的 速率向量 参数。

  14. RealT min() const;

    返回分布可以产生的最小值。

  15. RealT max() const;

    返回分布可以产生的最大值。

  16. param_type param() const;

    返回分布的参数。

  17. void param(param_type const & param);

    设置分布的参数。

  18. void reset();

    效果:随后的分布使用不依赖于调用 reset 之前的任何引擎生成的值。

`hyperexponential_distribution` 友元函数

  1. template<typename CharT, typename Traits> 
      std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > & os, 
                 const hyperexponential_distribution & hd);

    将 `hyperexponential_distribution` 写入 `std::ostream`。

  2. template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 const hyperexponential_distribution & hd);

    从 `std::istream` 读取 `hyperexponential_distribution`。

  3. bool operator==(const hyperexponential_distribution & lhs, 
                    const hyperexponential_distribution & rhs);

    如果两个 `hyperexponential_distribution` 实例在给定相等的生成器的情况下会返回相同的数值序列,则返回 true。

  4. bool operator!=(const hyperexponential_distribution & lhs, 
                    const hyperexponential_distribution & rhs);

    如果两个 `hyperexponential_distribution` 实例在给定相等的生成器的情况下会返回不同的数值序列,则返回 true。


PrevUpHomeNext