Loading...
Searching...
No Matches
Reproducibility

Typedefs

using Gudhi::random::Random_generator = std::mt19937_64
 

Functions

GUDHI_RANDOM_DLL_API Random_generatorGudhi::random::get_default_random ()
 Returns a thread-local default random number generator instance.
 
void Gudhi::random::set_seed (Random_generator::result_type seed)
 Sets the seed for the default random engine.
 
template<typename Type, typename CustomRandomGenerator = Random_generator&>
Type Gudhi::random::get_uniform (const Type &min, const Type &max, CustomRandomGenerator &&rng=get_default_random())
 Generates a random number in the range [min, max].
 
template<typename Type, typename CustomRandomGenerator = Random_generator&>
std::vector< Type > Gudhi::random::get_uniform_range (std::size_t nbr, const Type &min, const Type &max, CustomRandomGenerator &&rng=get_default_random())
 Generates a vector of N random numbers in the range [min, max].
 

Detailed Description

Some of the GUDHI functionnalities are using randomness. Here is a list of classes and methods that are using internally Gudhi::random::get_default_random (and are thus affected by Gudhi::random::set_seed):

In order to reproduce the results, a specific GUDHI random generator is available, and one can set its seed:

#include <gudhi/random.h>
// Set the seed for the default generator that is used internally in GUDHI
void set_seed(Random_generator::result_type seed)
Sets the seed for the default random engine.
Definition random.h:102

Typedef Documentation

◆ Random_generator

using Gudhi::random::Random_generator = std::mt19937_64

The default random number generator type returned by get_default_random

Function Documentation

◆ get_default_random()

Random_generator & Gudhi::random::get_default_random ( )
inline

Returns a thread-local default random number generator instance.

Returns
A reference to the thread-local default random instance.

◆ get_uniform()

template<typename Type, typename CustomRandomGenerator = Random_generator&>
Type Gudhi::random::get_uniform ( const Type & min,
const Type & max,
CustomRandomGenerator && rng = get_default_random() )

Generates a random number in the range [min, max].

Template Parameters
TypeThe type of the random number (must be integral or floating-point).
CustomRandomGeneratorThe type of the random generator. Default is Random_generator.
Parameters
minThe minimum value (inclusive).
maxThe maximum value (inclusive for integral types, but exclusive for floating-point types).
rngA random generator. Use the default one if not set.
Returns
A random number of type Type in the range [min, max].

◆ get_uniform_range()

template<typename Type, typename CustomRandomGenerator = Random_generator&>
std::vector< Type > Gudhi::random::get_uniform_range ( std::size_t nbr,
const Type & min,
const Type & max,
CustomRandomGenerator && rng = get_default_random() )

Generates a vector of N random numbers in the range [min, max].

Template Parameters
TypeThe type of the random numbers (must be integral or floating-point).
CustomRandomGeneratorThe type of the random generator. Default is Random_generator.
Parameters
nbrThe number of random numbers to generate.
minThe minimum value (inclusive).
maxThe maximum value (inclusive for integral types, but exclusive for floating-point types).
rngA random generator. Use the default one if not set.
Returns
A vector of random numbers of type Type in the range [min, max].
Examples
Random_bitmap_cubical_complex.cpp.

◆ set_seed()

void Gudhi::random::set_seed ( Random_generator::result_type seed)

Sets the seed for the default random engine.

Parameters
seedThe new seed value.