Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Random Variates and Distribution Parameters

Random variates and distribution parameters are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld by placing a semi-colon after the random variate (whose value you 'choose'), to separate the variate from the parameter(s) that defines the shape of the distribution.

For example, the binomial distribution has two parameters: n (the number of trials) and p (the probability of success on one trial). It also has the random variate k: the number of successes observed. This means the probability density/mass function (pdf) is written as f(k; n, p).

Translating this into code the binomial_distribution constructor therefore has two parameters:

binomial_distribution(RealType n, RealType p);

While the function pdf has one argument specifying the distribution type (which includes its parameters, if any), and a second argument for the random variate. So taking our binomial distribution example, we would write:

pdf(binomial_distribution<RealType>(n, p), k);