21template <
class T,
class G>
27 for (
auto i = 0uz; i + 1 < v.
size(); ++i)
32 auto const idx = i + dd(g);
48template <
class RandomNumberDistribution,
class Generator>
65template <
class RAIter,
class Generator>
86 "Selector only supports random access iterators.");
98template <
typename Iter,
typename Generator>
99Selector<Iter, Generator>
120 template <
class Generator>
149 template <
class Generator>
ConstantDistribution(double const &t)
double operator()(Generator &)
PowerLawDistribution(double xmin, double a)
double operator()(Generator &g)
std::uniform_real_distribution< double > uf_
Invocable that returns random samples from a range according to a discrete distribution.
std::discrete_distribution dd_
std::iterator_traits< RAIter >::value_type operator()()
Selector(RAIter first, RAIter last, std::vector< double > const &w, Generator &g)
Constructor.
Selector< Iter, Generator > makeSelector(Iter first, Iter last, std::vector< double > const &w, Generator &g)
std::vector< typename RandomNumberDistribution::result_type > sample(std::size_t size, RandomNumberDistribution dist, Generator &g)
Generate a vector of random samples.
std::vector< T > randomWeightedShuffle(std::vector< T > v, std::vector< double > w, G &g)
Return a randomly shuffled copy of vector based on weights w.