Gromacs
2024.3
|
#include <gromacs/random/tabulatednormaldistribution.h>
Tabulated normal random distribution.
Random distribution compatible with C++11 distributions - it can be used with any C++11 random engine.
RealType | Type of the return value. Float or double. Note that GROMACS uses "real" type by default in contrast to the C++11 standard library, to avoid double/float conversions. |
tableBits | Size of the table, specified in bits. The storage space required is sizeof(RealType)*2^tableBits. To keep things sane this is limited to 24 bits. |
Some stochastic integrators depend on drawing a lot of normal distribution random numbers quickly, but in many cases the only important property is the distribution - given the noise in forces we do not need very high resolution. This distribution uses an internal table to return samples from a normal distribution with limited resolution. By default the table uses c_TabulatedNormalDistributionDefaultBits bits, but this is specified with a template parameter.
Since this distribution only uses tableBits bits per value generated, the values draw from the random engine are used for several results. To make sure you get a reproducible result when using counter-based random engines (such as ThreeFry2x64), remember to call the reset() method to cancel the internal memory of the distribution.
Classes | |
class | param_type |
Normal distribution parameter class (mean and stddev) More... | |
Public Types | |
typedef RealType | result_type |
Type of normal distribution results. | |
Public Member Functions | |
TabulatedNormalDistribution (result_type mean=0.0, result_type stddev=1.0) | |
Construct new normal distribution with specified mean & stdddev. More... | |
TabulatedNormalDistribution (const param_type ¶m) | |
Construct new normal distribution from parameter type. More... | |
result_type | min () const |
Smallest value that can be generated in normal distributon. More... | |
result_type | max () const |
Largest value that can be generated in normal distribution. More... | |
result_type | mean () const |
Mean of the present normal distribution. | |
result_type | stddev () const |
Standard deviation of the present normal distribution. | |
param_type | param () const |
The parameter class (mean & stddev) of the normal distribution. | |
void | reset () |
Clear all internal saved random bits from the random engine. | |
template<class Rng > | |
result_type | operator() (Rng &g) |
Return normal distribution value specified by internal parameters. More... | |
template<class Rng > | |
result_type | operator() (Rng &g, const param_type ¶m) |
Return normal distribution value specified by given parameters. More... | |
bool | operator== (const TabulatedNormalDistribution< RealType, tableBits > &x) const |
Check if two tabulated normal distributions have identical states. More... | |
bool | operator!= (const TabulatedNormalDistribution< RealType, tableBits > &x) const |
Check if two tabulated normal distributions have different states. More... | |
Static Public Member Functions | |
static std::array< RealType, 1 << tableBits > | makeTable () |
Fill the table with values for the normal distribution. More... | |
|
inlineexplicit |
Construct new normal distribution with specified mean & stdddev.
mean | Mean value of tabulated normal distribution |
stddev | Standard deviation of tabulated normal distribution |
|
inlineexplicit |
Construct new normal distribution from parameter type.
param | Parameter class containing mean and standard deviation. |
|
inlinestatic |
Fill the table with values for the normal distribution.
This routine returns a new a std::array with the table data.
This routine is used to help construct objects of this class, and is exposed only to permit testing. Normal code should not need to call this function.
|
inline |
Largest value that can be generated in normal distribution.
|
inline |
Smallest value that can be generated in normal distributon.
|
inline |
Check if two tabulated normal distributions have different states.
x | Instance to compare with. |
|
inline |
Return normal distribution value specified by internal parameters.
Rng | Random engine type used to provide uniform random bits. |
g | Random engine of class Rng. For normal GROMACS usage you likely want to use ThreeFry2x64. |
|
inline |
Return normal distribution value specified by given parameters.
Rng | Random engine type used to provide uniform random bits. |
g | Random engine of class Rng. For normal GROMACS usage you likely want to use ThreeFry2x64. |
param | Parameters used to specify normal distribution. |
|
inline |
Check if two tabulated normal distributions have identical states.
x | Instance to compare with. |