...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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)
// 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"); };
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/destructbernoulli_distribution(RealType p = 0.5f);Creates a new bernoulli distribution.
~bernoulli_distribution();Destroys the
bernoulli_distribution
object.