Gromacs
2016.6
|
#include <gromacs/random/gammadistribution.h>
Gamma distribution.
The C++ standard library does provide a gamma distribution, but when using libstdc++-4.4.7 with at least gcc-4.6 or icc-14.0 the headers produce errors. Even for newer compilers, libstdc++ and libc++ appear to use different algorithms to generate it, which means their values differ in contrast to the uniform and normal distributions where they are identical. To avoid both the gcc-4.6 bug and make it easier to use GROMACS unit tests that depend on random numbers we have our own implementation.
Be warned that the gamma distribution works like the standard normal distribution and keeps drawing 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).
The gamma distribution is defined as
RealType | Floating-point type, real by default in GROMACS. |
Classes | |
class | param_type |
Gamma distribution parameters. More... | |
Public Types | |
typedef RealType | result_type |
Type of values returned. | |
Public Member Functions | |
GammaDistribution (result_type alpha=1.0, result_type beta=1.0) | |
Construct new distribution with given floating-point parameters. More... | |
GammaDistribution (const param_type ¶m) | |
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 gamma distribution with internal parameters. More... | |
template<class Rng > | |
result_type | operator() (Rng &g, const param_type ¶m) |
Return value from gamma distribution with given parameters. More... | |
result_type | alpha () const |
Return the first parameter of gamma distribution. | |
result_type | beta () const |
Return the second parameter of gamma distribution. | |
param_type | param () const |
Return the full parameter class of gamma distribution. | |
result_type | min () const |
Smallest value that can be returned from gamma distribution. | |
result_type | max () const |
Largest value that can be returned from gamma distribution. | |
bool | operator== (const GammaDistribution &x) const |
True if two gamma distributions will produce the same values. More... | |
bool | operator!= (const GammaDistribution &x) const |
True if two gamma distributions will produce different values. More... | |
|
inlineexplicit |
Construct new distribution with given floating-point parameters.
alpha | First parameter of gamma distribution |
beta | Second parameter of gamma distribution |
|
inlineexplicit |
Construct new distribution from parameter class.
param | Parameter class as defined inside gmx::GammaDistribution. |
|
inline |
True if two gamma distributions will produce different values.
x | Instance to compare with. |
|
inline |
Return values from gamma distribution with internal parameters.
Rng | Random engine class |
g | Random engine |
|
inline |
Return value from gamma distribution with given parameters.
Rng | Random engine class |
g | Random engine |
param | Parameters to use |
|
inline |
True if two gamma distributions will produce the same values.
x | Instance to compare with. |