| Home | Libraries | People | FAQ | More

## Class template poisson_distribution

boost::random::poisson_distribution

## Synopsis

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

        // construct/copy/destruct
        explicit param_type(RealType = 1);

        // public member functions
        RealType mean() const;

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

      // construct/copy/destruct
      explicit poisson_distribution(RealType = 1);
      explicit poisson_distribution(const param_type &);

      // public member functions
      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>
        friend std::basic_ostream< CharT, Traits > &
        operator<<(std::basic_ostream< CharT, Traits > &,
                   const poisson_distribution &);
      template<typename CharT, typename Traits>
        friend std::basic_istream< CharT, Traits > &
        operator>>(std::basic_istream< CharT, Traits > &, poisson_distribution &);
      friend bool operator==(const poisson_distribution &,
                             const poisson_distribution &);
      friend bool operator!=(const poisson_distribution &,
                             const poisson_distribution &);
    };

## Description

An instantiation of the class template `poisson_distribution` is a model of random distribution . The poisson distribution has

This implementation is based on the PTRD algorithm described

> "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` public construct/copy/destruct

1.     explicit poisson_distribution(RealType mean = 1);

   Constructs a ``poisson_distribution`` with the parameter `mean`.

   Requires: mean > 0

2.     explicit poisson_distribution(const param_type & param);

   Construct an ``poisson_distribution`` object from the parameters.

### `poisson_distribution` public member functions

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

   Returns a random variate distributed according to the poisson distribution.

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

   Returns a random variate distributed according to the poisson distribution with parameters specified by param.

3.     RealType mean() const;

   Returns the "mean" parameter of the distribution.

4.     IntType min() const;

   Returns the smallest value that the distribution can produce.

5.     IntType max() const;

   Returns the largest value that the distribution can produce.

6.     param_type param() const;

   Returns the parameters of the distribution.

7.     void param(const param_type & param);

   Sets parameters of the distribution.

8.     void reset();

   Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.

### `poisson_distribution` friend functions

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

   Writes the parameters of the distribution to a `std::ostream`.

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

   Reads the parameters of the distribution from a `std::istream`.

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

   Returns true if the two distributions will produce the same sequence of values, given equal generators.

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

   Returns true if the two distributions could produce different sequences of values, given equal generators.