Gromacs  2016.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions
gmx::NormalDistribution< RealType > Class Template Reference

#include <gromacs/random/normaldistribution.h>

Description

template<class RealType = real>
class gmx::NormalDistribution< RealType >

Normal distribution.

The C++ standard library does provide a normal distribution, but even though they all sample from the normal distribution different standard library implementations appear to return different sequences of numbers for the same random number generator. To make it easier to use GROMACS unit tests that depend on random numbers we have our own implementation.

Be warned that the normal distribution draws values from the random engine in a loop, so you want to make sure you use a random stream with a very large margin to make sure you do not run out of random numbers in an unlucky case (which will lead to an exception with the GROMACS default random engine).

Template Parameters
RealTypeFloating-point type, real by default in GROMACS.

Classes

class  param_type
 Normal distribution parameters. More...
 

Public Types

typedef RealType result_type
 Type of values returned.
 

Public Member Functions

 NormalDistribution (result_type mean=0.0, result_type stddev=1.0)
 Construct new distribution with given floating-point parameters. More...
 
 NormalDistribution (const param_type &param)
 Construct new distribution from parameter class. More...
 
void reset ()
 Flush all internal saved values.
 
template<class Rng >
result_type operator() (Rng &g)
 Return values from normal distribution with internal parameters. More...
 
template<class Rng >
result_type operator() (Rng &g, const param_type &param)
 Return value from normal distribution with given parameters. More...
 
result_type mean () const
 Return the mean of the normal distribution.
 
result_type stddev () const
 Return the standard deviation of the normal distribution.
 
param_type param () const
 Return the full parameter class of the normal distribution.
 
result_type min () const
 Smallest value that can be returned from normal distribution.
 
result_type max () const
 Largest value that can be returned from normal distribution.
 
bool operator== (const NormalDistribution &x) const
 True if two normal distributions will produce the same values. More...
 
bool operator!= (const NormalDistribution &x) const
 True if two normal distributions will produce different values. More...
 

Constructor & Destructor Documentation

template<class RealType = real>
gmx::NormalDistribution< RealType >::NormalDistribution ( result_type  mean = 0.0,
result_type  stddev = 1.0 
)
inlineexplicit

Construct new distribution with given floating-point parameters.

Parameters
meanMean of normal distribution
stddevStandard deviation of normal distribution
template<class RealType = real>
gmx::NormalDistribution< RealType >::NormalDistribution ( const param_type param)
inlineexplicit

Construct new distribution from parameter class.

Parameters
paramParameter class as defined inside gmx::NormalDistribution.

Member Function Documentation

template<class RealType = real>
bool gmx::NormalDistribution< RealType >::operator!= ( const NormalDistribution< RealType > &  x) const
inline

True if two normal distributions will produce different values.

Parameters
xInstance to compare with.
template<class RealType = real>
template<class Rng >
result_type gmx::NormalDistribution< RealType >::operator() ( Rng &  g)
inline

Return values from normal distribution with internal parameters.

Template Parameters
RngRandom engine class
Parameters
gRandom engine
template<class RealType = real>
template<class Rng >
result_type gmx::NormalDistribution< RealType >::operator() ( Rng &  g,
const param_type param 
)
inline

Return value from normal distribution with given parameters.

Template Parameters
RngRandom engine class
Parameters
gRandom engine
paramParameters to use
template<class RealType = real>
bool gmx::NormalDistribution< RealType >::operator== ( const NormalDistribution< RealType > &  x) const
inline

True if two normal distributions will produce the same values.

Parameters
xInstance to compare with.

The documentation for this class was generated from the following file: