public member function
<random>

std::poisson_distribution::(constructor)

(1)
explicit poisson_distribution ( double mean = 1.0 );
(2)
explicit poisson_distribution ( const param_type& parm );
Construct Poisson distribution
Constructs a poisson_distribution object, adopting the distribution parameter specified either by mean or by object parm.

Parameters

mean
Expected number of events in the interval (μ).
This represents the rate at which the events being counted are observed, on average.
Its value shall be positive (μ>0).
parm
An object representing the distribution's parameters, obtained by a call to member function param.
param_type is a member type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// poisson_distribution example
#include <iostream>
#include <chrono>
#include <random>

int main()
{
  // construct a trivial random generator engine from a time-based seed:
  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
  std::default_random_engine generator (seed);

  std::poisson_distribution<int> distribution (5.2);

  std::cout << "some Poisson-distributed results (mean=5.2): ";
  for (int i=0; i<10; ++i)
    std::cout << distribution(generator) << " ";

  std::cout << std::endl;

  return 0;
}

Possible output:
some Poisson-distributed results (mean=5.2): 5 5 9 7 3 1 5 7 7 2


Complexity

Constant.

See also