| Home | Libraries | People | FAQ | More

## Class template normal_distribution

boost::compute::normal_distribution — Produces random, normally-distributed floating-point numbers.

## Synopsis

    // 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 BOOST_PREVENT_MACRO_SUBSTITUTION() const;
      result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() 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 normal distribution to produce random `float` values centered at `5`:

See Also:

default_random_engine, uniform_real_distribution

### `normal_distribution` public construct/copy/destruct

1.     normal_distribution(RealType mean = 0.f, RealType stddev = 1.f);

   Creates a new normal distribution producing numbers with the given `mean` and `stddev`.

2.     ~normal_distribution();

   Destroys the normal distribution object.

### `normal_distribution` public member functions

1.     result_type mean() const;

   Returns the mean value of the distribution.

2.     result_type stddev() const;

   Returns the standard-deviation of the distribution.

3.     result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const;

   Returns the minimum value of the distribution.

4.     result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const;

   Returns the maximum value of the distribution.

5.     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`).

### `normal_distribution` private member functions

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