Boost C++ 库

...世界上备受推崇且设计精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

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

类模板 poisson_distribution

boost::poisson_distribution

提要

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

template<typename IntType = int, typename RealType = double> 
class poisson_distribution {
public:
  // types
  typedef IntType  result_type;
  typedef RealType input_type; 

  // member classes/structs/unions

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

    // public member functions
    explicit param_type(RealType = 1);
    RealType mean() 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 > &, param_type &);
    bool operator==(const param_type &, const param_type &);
    bool operator!=(const param_type &, const param_type &);
  };

  // public member functions
  explicit poisson_distribution(RealType = 1);
  explicit poisson_distribution(const param_type &);
  template<typename URNG> IntType operator()(URNG &) const;
  template<typename URNG> IntType operator()(URNG &, const param_type &) const;
  RealType mean() const;
  IntType min() const;
  IntType max() const;
  param_type param() const;
  void param(const param_type &);
  void reset();

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

描述

类模板 poisson_distribution 的一个实例是 随机分布 的模型。泊松分布具有

此实现基于 PTRD 算法,该算法在以下文献中进行了描述:

"The transformed rejection method for generating Poisson random variables", Wolfgang Hormann, Insurance: Mathematics and Economics Volume 12, Issue 1, February 1993, Pages 39-45

poisson_distribution 公有成员函数

  1. explicit poisson_distribution(RealType mean = 1);

    使用参数 mean 构建 poisson_distribution

    要求:mean > 0

  2. explicit poisson_distribution(const param_type & param);

    从参数构造 poisson_distribution 对象。

  3. template<typename URNG> IntType operator()(URNG & urng) const;

    返回一个根据泊松分布分布的随机变量。

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

    返回一个根据由 param 指定的参数的泊松分布分布的随机变量。

  5. RealType mean() const;

    返回分布的“均值”参数。

  6. IntType min() const;

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

  7. IntType max() const;

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

  8. param_type param() const;

    返回分布的参数。

  9. void param(const param_type & param);

    设置分布的参数。

  10. void reset();

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

poisson_distribution 友元函数

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

    将分布的参数写入 std::ostream

  2. template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 poisson_distribution & pd);

    std::istream 读取分布的参数。

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

    如果两个分布在给定相同的生成器时会产生相同的数值序列,则返回 true。

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

    如果两个分布在给定相同的生成器时可能产生不同的数值序列,则返回 true。


PrevUpHomeNext