...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::binomial_distribution
// In header: <boost/random/binomial_distribution.hpp> template<typename IntType = int, typename RealType = double> class binomial_distribution { public: // types typedef bernoulli_distribution< RealType >::input_type input_type; typedef IntType result_type; // construct/copy/destruct binomial_distribution(IntType = 1, const RealType & = RealType(0.5)); // public member functions IntType t() const; RealType p() const; void reset(); template<typename Engine> result_type operator()(Engine &); // friend functions template<typename CharT, typename Traits> friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &, const binomial_distribution &); template<typename CharT, typename Traits> friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &, binomial_distribution &); };
The binomial distribution is an integer valued distribution with two parameters, t
and p
. The values of the distribution are within the range [0,t].
The probability that the distribution produces a value k is .
binomial_distribution
public member functionsIntType t() const;
Returns: the t
parameter of the distribution
RealType p() const;
Returns: the p
parameter of the distribution
void reset();
Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.
template<typename Engine> result_type operator()(Engine & eng);
Returns: a random variate distributed according to the binomial distribution.
binomial_distribution
friend functionstemplate<typename CharT, typename Traits> friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > & os, const binomial_distribution & bd);
Writes the parameters of the distribution to a std::ostream
.
template<typename CharT, typename Traits> friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, binomial_distribution & bd);
Reads the parameters of the distribution from a std::istream
.