AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
autopas::Random Class Reference

Class for random algorithms. More...

#include <Random.h>

Inheritance diagram for autopas::Random:
Inheritance graph
[legend]
Collaboration diagram for autopas::Random:
Collaboration graph
[legend]

Public Member Functions

 Random (unsigned long seed=std::random_device()())
 Constructor.
 
 Random (const Random &other)=delete
 Class should not be copied constructed.
 
Randomoperator= (const Random &other)=delete
 Class should not be copied assigned.
 
template<class Iter >
std::vector< typename std::iterator_traits< Iter >::value_type > uniformSample (Iter poolBegin, Iter poolEnd, size_t n)
 Sample n points from the pool.
 
std::vector< size_t > uniformSample (size_t min, size_t max, size_t n)
 Sample n points from the set {min;min+1;...;max}.
 
template<class Container >
auto pickRandom (const Container &pool)
 Get a uniformly randomly selected object from the given container.
 
template<class T >
std::set< T > randomSubset (std::set< T > pool, size_t n)
 Pick up to n random elements from the set.
 

Detailed Description

Class for random algorithms.

Constructor & Destructor Documentation

◆ Random() [1/2]

autopas::Random::Random ( unsigned long  seed = std::random_device()())
inlineexplicit

Constructor.

Parameters
seed

◆ Random() [2/2]

autopas::Random::Random ( const Random other)
delete

Class should not be copied constructed.

Parameters
other

Member Function Documentation

◆ operator=()

Random & autopas::Random::operator= ( const Random other)
delete

Class should not be copied assigned.

Parameters
other
Returns

◆ pickRandom()

template<class Container >
auto autopas::Random::pickRandom ( const Container &  pool)
inline

Get a uniformly randomly selected object from the given container.

Template Parameters
ContainerType of the container. Must support std::begin().
ElemType of the elements in the container.
Parameters
poolContainer from which to select an element.
Returns
Randomly selected element.

◆ randomSubset()

template<class T >
std::set< T > autopas::Random::randomSubset ( std::set< T >  pool,
size_t  n 
)
inline

Pick up to n random elements from the set.

Each elements has the same probability to be chosen

Parameters
poolset
nnumber of elements
Returns
n random elements

◆ uniformSample() [1/2]

template<class Iter >
std::vector< typename std::iterator_traits< Iter >::value_type > autopas::Random::uniformSample ( Iter  poolBegin,
Iter  poolEnd,
size_t  n 
)
inline

Sample n points from the pool.

Each element in the pool will appear about the same number of times in the sample.

Template Parameters
Ttype of the elements
Parameters
poolBegin
poolEnd
nnumber samples
Returns
samples

◆ uniformSample() [2/2]

std::vector< size_t > autopas::Random::uniformSample ( size_t  min,
size_t  max,
size_t  n 
)
inline

Sample n points from the set {min;min+1;...;max}.

Each element in the set will appear about the same number of times in the sample.

Parameters
min
max
nnumber samples
Returns
samples

The documentation for this class was generated from the following file: