File weight_sampling.hpp¶
Functions
-
template<typename Iterator>
static inline void sampleWeightsWithoutReplacementViaTrackingSelection(BitWeightVector &weightVector, Iterator iterator, uint32 numTotal, uint32 numSamples, RNG &rng)¶ Randomly selects
numSamples
out ofnumTotal
elements and sets their weights to 1, while the remaining weights are set to 0, by using a set to keep track of the elements that have already been selected. This method is suitable ifnumSamples
is much smaller thannumTotal
.- Template Parameters:
Iterator – The type of the iterator that provides random access to the indices of the available elements to sample from
- Parameters:
weightVector – A reference to an object of type
BitWeightVector
the weights should be written toiterator – An iterator that provides random access to the indices of the available elements to sample from
numTotal – The total number of available elements to sample from
numSamples – The number of weights to be set to 1
rng – A reference to an object of type
RNG
, implementing the random number generator to be used
-
template<typename Iterator>
static inline void sampleWeightsWithoutReplacementViaPool(BitWeightVector &weightVector, Iterator iterator, uint32 numTotal, uint32 numSamples, RNG &rng)¶ Randomly selects
numSamples
out ofnumTotal
elements and sets their weights to 1, while the remaining weights are set to 0, by using a pool, i.e., an array, to keep track of the elements that have not been selected yet.- Template Parameters:
Iterator – The type of the iterator that provides random access to the indices of the available elements to sample from
- Parameters:
weightVector – A reference to an object of type
BitWeightVector
the weights should be written toiterator – An iterator that provides random access to the indices of the available elements to sample from
numTotal – The total number of available elements to sample from
numSamples – The number of weights to be set to 1
rng – A reference to an object of type
RNG
, implementing the random number generator to be used
-
template<typename Iterator>
static inline void sampleWeightsWithoutReplacement(BitWeightVector &weightVector, Iterator iterator, uint32 numTotal, uint32 numSamples, RNG &rng)¶ Randomly selects
numSamples
out ofnumTotal
elements and sets their weights to 1, while the remaining weights are set to 0. The method that is used internally is chosen automatically, depending on the rationumSamples / numTotal
.- Template Parameters:
Iterator – The type of the iterator that provides random access to the indices of the available elements to sample from
- Parameters:
weightVector – A reference to an object of type
BitWeightVector
the weights should be written toiterator – An iterator that provides random access to the indices of the available elements to sample from
numTotal – The total number of available elements to sample from
numSamples – The number of weights to be set to 1
rng – A reference to an object of type
RNG
, implementing the random number generator to be used