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 the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template bernoulli_distribution

boost::compute::bernoulli_distribution — Produces random boolean values according to the following discrete probability function with parameter p : P(true/p) = p and P(false/p) = (1 - p)

Synopsis

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

template<typename RealType = float> 
class bernoulli_distribution {
public:
  // construct/copy/destruct
  bernoulli_distribution(RealType = 0.5f);
  ~bernoulli_distribution();

  // public member functions
  RealType p() const;
  template<typename OutputIterator, typename Generator> 
    void generate(OutputIterator, OutputIterator, Generator &, 
                  command_queue &);

  // private member functions
   BOOST_STATIC_ASSERT_MSG(boost::is_floating_point< RealType >::value, 
                           "Template argument must be a floating point type");
};

Description

The following example shows how to setup a bernoulli distribution to produce random boolean values with parameter p = 0.25


bernoulli_distribution public construct/copy/destruct

  1. bernoulli_distribution(RealType p = 0.5f);
    Creates a new bernoulli distribution.
  2. ~bernoulli_distribution();
    Destroys the bernoulli_distribution object.

bernoulli_distribution public member functions

  1. RealType p() const;
    Returns the value of the parameter p.
  2. template<typename OutputIterator, typename Generator> 
      void generate(OutputIterator first, OutputIterator last, 
                    Generator & generator, command_queue & queue);

    Generates bernoulli distributed booleans and stores them in the range [first, last).

bernoulli_distribution private member functions

  1.  BOOST_STATIC_ASSERT_MSG(boost::is_floating_point< RealType >::value, 
                             "Template argument must be a floating point type");

PrevUpHomeNext