Boost C++ 库

…这是世界上最受尊敬、设计最精巧的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ 编码标准

类模板 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-阶段的 hyperexponential_distribution(即指数分布),速率为 1。

  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

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

    参考文献

    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,并具有相等的阶段概率。

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

    参考文献

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

    参数

    l1

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

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

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

    参数

    urng

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

    模板参数

    URNG

    必须满足均匀随机数生成器的要求。

    返回

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

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

    获取一个按照超指数分布且其参数由 param 指定的随机变量。

    参数

    urng

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

    param

    一个分布参数对象。

    模板参数

    URNG

    必须满足均匀随机数生成器的要求。

    返回

    一个按照超指数分布且其参数由 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