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

Click here to view the latest version of this page.
PrevUpHomeNext

Class template normal_distribution

boost::random::normal_distribution

Synopsis

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

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

  // member classes/structs/unions

  class param_type {
  public:
    // types
    typedef normal_distribution distribution_type;

    // construct/copy/destruct
    explicit param_type(RealType = 0.0, RealType = 1.0);

    // public member functions
    RealType mean() const;
    RealType sigma() const;

    // friend functions
    template<typename CharT, typename Traits> 
      friend std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > &, const param_type &);
    template<typename CharT, typename Traits> 
      friend std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > &, const param_type &);
    friend bool operator==(const param_type &, const param_type &);
    friend bool operator!=(const param_type &, const param_type &);
  };

  // construct/copy/destruct
  explicit normal_distribution(const RealType & = 0.0, const RealType & = 1.0);
  explicit normal_distribution(const param_type &);

  // public member functions
  RealType mean() const;
  RealType sigma() const;
  RealType min() const;
  RealType max() const;
  param_type param() const;
  void param(const param_type &);
  void reset();
  template<typename Engine> result_type operator()(Engine &);
  template<typename URNG> result_type operator()(URNG &, const param_type &);

  // friend functions
  template<typename CharT, typename Traits> 
    friend std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, 
               const normal_distribution &);
  template<typename CharT, typename Traits> 
    friend std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               const normal_distribution &);
  friend bool operator==(const normal_distribution &, 
                         const normal_distribution &);
  friend bool operator!=(const normal_distribution &, 
                         const normal_distribution &);
};

Description

Instantiations of class template normal_distribution model a random distribution . Such a distribution produces random numbers x distributed with probability density function , where mean and sigma are the parameters of the distribution.

normal_distribution public construct/copy/destruct

  1. explicit normal_distribution(const RealType & mean = 0.0, 
                                 const RealType & sigma = 1.0);

    Constructs a normal_distribution object. mean and sigma are the parameters for the distribution.

    Requires: sigma >= 0

  2. explicit normal_distribution(const param_type & param);

    Constructs a normal_distribution object from its parameters.

normal_distribution public member functions

  1. RealType mean() const;

    Returns the mean of the distribution.

  2. RealType sigma() const;

    Returns the standard deviation of the distribution.

  3. RealType min() const;

    Returns the smallest value that the distribution can produce.

  4. RealType max() const;

    Returns the largest value that the distribution can produce.

  5. param_type param() const;

    Returns the parameters of the distribution.

  6. void param(const param_type & param);

    Sets the parameters of the distribution.

  7. void reset();

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

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

    Returns a normal variate.

  9. template<typename URNG> 
      result_type operator()(URNG & urng, const param_type & param);

    Returns a normal variate with parameters specified by param.

normal_distribution friend functions

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

    Writes a normal_distribution to a std::ostream.

  2. template<typename CharT, typename Traits> 
      friend std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 const normal_distribution & nd);

    Reads a normal_distribution from a std::istream.

  3. friend bool operator==(const normal_distribution & lhs, 
                           const normal_distribution & rhs);

    Returns true if the two instances of normal_distribution will return identical sequences of values given equal generators.

  4. friend bool operator!=(const normal_distribution & lhs, 
                           const normal_distribution & rhs);

    Returns true if the two instances of normal_distribution will return different sequences of values given equal generators.


PrevUpHomeNext