[mrpt-random]

Random number generator C++ library support uniform, Gaussian, multivariable distributions.

Library mrpt-random

This library is part of MRPT but it’s pure C++11 and has no other dependencies. It can be installed in Debian-based systems with:

sudo apt install libmrpt-random-dev

Read also how to import MRPT into your CMake scripts.

Library contents

// namespaces

namespace mrpt::random;

// classes

class mrpt::random::CRandomGenerator;
class mrpt::random::Generator_MT19937;

// global functions

template <class URBG>
uint64_t mrpt::random::portable_uniform_distribution(URBG&& g, uint64_t min, uint64_t max);

template <class RandomIt, class URBG>
void mrpt::random::shuffle(
    RandomIt first,
    RandomIt last,
    URBG&& g
    );

template <class RandomIt>
void mrpt::random::shuffle(RandomIt first, RandomIt last);

template <class RandomIt, class URBG>
void mrpt::random::partial_shuffle(
    RandomIt first,
    RandomIt last,
    URBG&& g,
    size_t N
    );

Global Functions

template <class URBG>
uint64_t mrpt::random::portable_uniform_distribution(
    URBG&& g,
    uint64_t min,
    uint64_t max
    )

A compiler and platform-independent uniform distribution generator.

Parameters:

URGB

Can be a C++11 std random generator, or mrpt::random::Generator_MT19937

template <class RandomIt, class URBG>
void mrpt::random::shuffle(
    RandomIt first,
    RandomIt last,
    URBG&& g
    )

Uniform shuffle a sequence.

template <class RandomIt>
void mrpt::random::shuffle(
    RandomIt first,
    RandomIt last
    )

Uniform shuffle a sequence.

template <class RandomIt, class URBG>
void mrpt::random::partial_shuffle(
    RandomIt first,
    RandomIt last,
    URBG&& g,
    size_t N
    )

Shuffle the first N elements of a sequence.

Note that elements at positions [N:end] may also change if they are randomly picked for permutation with the first [0,N-1] elements.

[New in MRPT 2.4.0]