boost::compute::normal_distribution — Produces random, normally-distributed floating-point numbers.
// In header: <boost/compute/random/normal_distribution.hpp> template<typename RealType = float> class normal_distribution { public: // types typedef RealType result_type; // construct/copy/destruct normal_distribution(RealType = 0.f, RealType = 1.f); ~normal_distribution(); // public member functions result_type mean() const; result_type stddev() const; result_type min() const; result_type max() const; template<typename OutputIterator, typename Generator> void generate(OutputIterator, OutputIterator, Generator &, command_queue &); };
The following example shows how to setup a normal distribution to produce random float
values centered at 5
:
// initialize the default random engine boost::compute::default_random_engine engine(queue); // setup the normal distribution to produce floats centered at 5 boost::compute::normal_distribution<float> distribution(5.0f, 1.0f); // generate the random values and store them to 'vec' distribution.generate(vec.begin(), vec.end(), engine, queue);
See Also:
default_random_engine, uniform_real_distribution
normal_distribution
public member functionsresult_type mean() const;Returns the mean value of the distribution.
result_type stddev() const;Returns the standard-deviation of the distribution.
result_type min() const;Returns the minimum value of the distribution.
result_type max() const;Returns the maximum value of the distribution.
template<typename OutputIterator, typename Generator> void generate(OutputIterator first, OutputIterator last, Generator & generator, command_queue & queue);
Generates normally-distributed floating-point numbers and stores them to the range [first
, last
).