28
Numerics library
[numerics]
28.5
Random number generation
[rand]
28.5.9
Random number distribution class templates
[rand.dist]
28.5.9.4
Poisson distributions
[rand.dist.pois]
28.5.9.4.1
Class template
poisson_
distribution
[rand.dist.pois.poisson]
1
#
A
poisson_
distribution
random number distribution produces integer values
i
≥ 0
distributed according to the discrete probability function in Formula
28.8
.
P
(
i
|
μ
)
=
e
−
μ
μ
i
i
!
(28.8)
The distribution parameter
μ
is also known as this distribution's
mean
.
🔗
namespace
std
{
template
<
class
IntType
=
int
>
class
poisson_distribution
{
public
:
// types
using
result_type
=
IntType;
using
param_type
=
unspecified
;
// constructors and reset functions
poisson_distribution
(
)
:
poisson_distribution
(
1.0
)
{
}
explicit
poisson_distribution
(
double
mean
)
;
explicit
poisson_distribution
(
const
param_type
&
parm
)
;
void
reset
(
)
;
// equality operators
friend
bool
operator
=
=
(
const
poisson_distribution
&
x,
const
poisson_distribution
&
y
)
;
// generating functions
template
<
class
URBG
>
result_type
operator
(
)
(
URBG
&
g
)
;
template
<
class
URBG
>
result_type
operator
(
)
(
URBG
&
g,
const
param_type
&
parm
)
;
// property functions
double
mean
(
)
const
; param_type param
(
)
const
;
void
param
(
const
param_type
&
parm
)
; result_type min
(
)
const
; result_type max
(
)
const
;
// inserters and extractors
template
<
class
charT,
class
traits
>
friend
basic_ostream
<
charT, traits
>
&
operator
<
<
(
basic_ostream
<
charT, traits
>
&
os,
const
poisson_distribution
&
x
)
;
template
<
class
charT,
class
traits
>
friend
basic_istream
<
charT, traits
>
&
operator
>
>
(
basic_istream
<
charT, traits
>
&
is, poisson_distribution
&
x
)
;
}
;
}
🔗
explicit
poisson_distribution
(
double
mean
)
;
2
#
Preconditions
:
0
<
mean
.
3
#
Remarks
:
mean
corresponds to the parameter of the distribution
.
🔗
double
mean
(
)
const
;
4
#
Returns
: The value of the
mean
parameter with which the object was constructed
.