inlib  1.2.0
Public Member Functions
inlib::random::gauss Class Reference

List of all members.

Public Member Functions

 gauss (double a_mean=0, double a_std_dev=1)
 gauss (const gauss &a_from)
gaussoperator= (const gauss &a_from)
double shoot () const

Detailed Description

Definition at line 25 of file random.


Constructor & Destructor Documentation

inlib::random::gauss::gauss ( double  a_mean = 0,
double  a_std_dev = 1 
) [inline]

Definition at line 27 of file random.

  :m_mean(a_mean),m_std_dev(a_std_dev){}
inlib::random::gauss::gauss ( const gauss a_from) [inline]

Definition at line 30 of file random.

  :m_mean(a_from.m_mean),m_std_dev(a_from.m_std_dev){}

Member Function Documentation

gauss& inlib::random::gauss::operator= ( const gauss a_from) [inline]

Definition at line 32 of file random.

                                        {
    m_mean = a_from.m_mean;
    m_std_dev = a_from.m_std_dev;
    return *this;
  }
double inlib::random::gauss::shoot ( ) const [inline]

Definition at line 38 of file random.

                       {
    //  Shoot random numbers according a 
    // gaussian distribution of mean 0 and sigma 1.
    double v1,v2,r,fac;
    do {
      v1 = 2.0 * m_flat.shoot() - 1.0;
      v2 = 2.0 * m_flat.shoot() - 1.0;
      r = v1*v1 + v2*v2;
    }   while ( r > 1.0 );
    fac = ::sqrt(-2.0*::log(r)/r);
    return (v2 * fac) * m_std_dev + m_mean;
  }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines