ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/math/MersenneTwister.hpp
(Generate patch)

Comparing trunk/OOPSE-4/src/math/MersenneTwister.hpp (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2632 by tim, Thu Mar 16 22:50:48 2006 UTC

# Line 112 | Line 112 | namespace oopse {
112      double rand53();  // real number in [0,1)
113          
114      // Access to nonuniform random number distributions
115 <    double randNorm( const double& mean = 0.0, const double& variance = 0.0 );
115 >    double randNorm( const double mean = 0.0, const double variance = 0.0 );
116          
117      // Re-seeding functions with same behavior as initializers
118      void seed( const uint32 oneSeed );
# Line 180 | Line 180 | namespace oopse {
180      return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0);  // by Isaku Wada
181    }
182  
183 <  inline double MTRand::randNorm( const double& mean, const double& variance )
183 >  inline double MTRand::randNorm( const double mean, const double variance )
184    {
185      // Return a real number from a normal (Gaussian) distribution with given
186      // mean and variance by Box-Muller method
187 <    double r = sqrt( -2.0 * log( 1.0-randDblExc()) ) * variance;
187 >    assert(variance > 0);
188 >    double r = sqrt( -2.0 * log( 1.0-randDblExc()) * variance);
189      double phi = 2.0 * 3.14159265358979323846264338328 * randExc();
190      return mean + r * cos(phi);
191    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines