Kea  1.9.9-git
isc::util::random::WeightedRandomIntegerGenerator Class Reference

Weighted random integer generator. More...

#include <random_number_generator.h>

Public Member Functions

 WeightedRandomIntegerGenerator (const std::vector< double > &probabilities, size_t min=0)
 Constructor. More...
 WeightedRandomIntegerGenerator ()
 Default constructor. More...
size_t operator() ()
 Generate weighted random integer. More...
void reset (const std::vector< double > &probabilities, size_t min=0)
 Reset the probabilities. More...

Detailed Description

Weighted random integer generator.

Generate random integers according different probabilities

Definition at line 91 of file random_number_generator.h.

Constructor & Destructor Documentation

isc::util::random::WeightedRandomIntegerGenerator::WeightedRandomIntegerGenerator ( const std::vector< double > &  probabilities,
size_t  min = 0 


probabilitiesThe probabilities for all the integers, the probability must be between 0 and 1.0, the sum of probabilities must be equal to 1. For example, if the probabilities contains the following values: 0.5 0.3 0.2, the 1st integer will be generated more frequently than the other integers and the probability is proportional to its value.
minThe minimum integer that generated, other integers will be min, min + 1, ..., min + probabilities.size() - 1

Definition at line 102 of file random_number_generator.h.

isc::util::random::WeightedRandomIntegerGenerator::WeightedRandomIntegerGenerator ( )

Default constructor.

Definition at line 119 of file random_number_generator.h.

Member Function Documentation

size_t isc::util::random::WeightedRandomIntegerGenerator::operator() ( )

Generate weighted random integer.

Definition at line 146 of file random_number_generator.h.

void isc::util::random::WeightedRandomIntegerGenerator::reset ( const std::vector< double > &  probabilities,
size_t  min = 0 

Reset the probabilities.

Change the weights of each integers

probabilitiesThe probabilities for all the integers
minThe minimum integer that generated

Definition at line 129 of file random_number_generator.h.

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