Boost C++ Libraries

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

This is an old version of boost. Click here for the latest version's documentation home page.
PrevUpHomeNext

Class template bernoulli_distribution

boost::bernoulli_distribution

Synopsis

// In header: <boost/random/bernoulli_distribution.hpp>

template<typename RealType = double> 
class bernoulli_distribution {
public:
  // types
  typedef int  input_type; 
  typedef bool result_type;

  // construct/copy/destruct
  bernoulli_distribution(const RealType & = RealType(0.5));

  // public member functions
  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 bernoulli_distribution &);
  template<typename CharT, typename Traits> 
    friend std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               bernoulli_distribution &);
};

Description

Instantiations of class template bernoulli_distribution model a random distribution . Such a random distribution produces bool values distributed with probabilities P(true) = p and P(false) = 1-p. p is the parameter of the distribution.

bernoulli_distribution public construct/copy/destruct

  1. bernoulli_distribution(const RealType & p_arg = RealType(0.5));

    Constructs a bernoulli_distribution object. p is the parameter of the distribution.

    Requires: 0 <= p <= 1

bernoulli_distribution public member functions

  1. RealType p() const;

    Returns: The "p" parameter of the distribution.

  2. void reset();

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

  3. template<typename Engine> result_type operator()(Engine & eng);

    Returns: a random variate distributed according to the bernoulli_distribution .

bernoulli_distribution friend functions

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

    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, 
                 bernoulli_distribution & bd);

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


PrevUpHomeNext