ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Random Namespace Reference

Functions

template<RNGSalt salt>
auto philox_4_uint64s (uint64_t counter, uint32_t seed, int key1, int key2=0)
 get 4 random uint 64 from the Philox RNG
 
template<RNGSalt salt, std::size_t N = 3, std::enable_if_t<(N > 1) and(N<=4), int > = 0>
auto noise_uniform (uint64_t counter, uint32_t seed, int key1, int key2=0)
 Generator for random uniform noise.
 
template<RNGSalt salt, std::size_t N = 3, class = std::enable_if_t<(N >= 1) and (N <= 4)>>
auto noise_gaussian (uint64_t counter, uint32_t seed, int key1, int key2=0)
 Generator for Gaussian noise.
 
template<typename T >
std::mt19937 mt19937 (T &&seed)
 Mersenne Twister with warmup.
 

Function Documentation

◆ mt19937()

template<typename T >
std::mt19937 Random::mt19937 ( T &&  seed)

Mersenne Twister with warmup.

The first 100'000 values of Mersenne Twister generators are often heavily correlated [32]. This utility function discards the first 1'000'000 values.

Parameters
seedRNG seed

Definition at line 194 of file random.hpp.

Referenced by draw_polymer_positions().

◆ noise_gaussian()

template<RNGSalt salt, std::size_t N = 3, class = std::enable_if_t<(N >= 1) and (N <= 4)>>
auto Random::noise_gaussian ( uint64_t  counter,
uint32_t  seed,
int  key1,
int  key2 = 0 
)

Generator for Gaussian noise.

Mean = 0, standard deviation = 1.0. Based on the Philox RNG using 4x64 bits. The Box-Muller transform is used to convert from uniform to normal distribution. The transform is only valid, if the uniformly distributed random numbers are not zero (approx one in 2^64). To avoid this case, such numbers are replaced by std::numeric_limits<double>::min() This breaks statistics in rare cases but allows for consistent RNG counters across MPI ranks.

Template Parameters
saltdecorrelates different thermostat types
Parameters
countercounter for random number generation
seedseed for random number generation
key1key for random number generation
key2key for random number generation
Returns
Vector of Gaussian random numbers.

Definition at line 150 of file random.hpp.

◆ noise_uniform()

template<RNGSalt salt, std::size_t N = 3, std::enable_if_t<(N > 1) and(N<=4), int > = 0>
auto Random::noise_uniform ( uint64_t  counter,
uint32_t  seed,
int  key1,
int  key2 = 0 
)

Generator for random uniform noise.

Mean = 0, variance = 1 / 12. This uses the Philox PRNG, the state is controlled by the counter, the salt and two keys. If any of the keys and salt differ, the noise is not correlated between two calls along the same counter sequence.

Template Parameters
saltRNG salt
NSize of the noise vector
Parameters
countercounter for random number generation
seedseed for random number generation
key1key for random number generation
key2key for random number generation
Returns
Vector of uniform random numbers.

Definition at line 112 of file random.hpp.

◆ philox_4_uint64s()

template<RNGSalt salt>
auto Random::philox_4_uint64s ( uint64_t  counter,
uint32_t  seed,
int  key1,
int  key2 = 0 
)

get 4 random uint 64 from the Philox RNG

This uses the Philox PRNG, the state is controlled by the counter, the salt and two keys. If any of the keys and salt differ, the noise is not correlated between two calls along the same counter sequence.

Definition at line 75 of file random.hpp.

References Utils::u32_to_u64().