Kea: isc::util::random::WeightedRandomIntegerGenerator Class Reference

| Kea 1.5.0

Public Member Functions | List of all members
isc::util::random::WeightedRandomIntegerGenerator Class Reference

Weighted random integer generator. More...

`#include <random_number_generator.h>`

## Public Member Functions
| WeightedRandomIntegerGenerator ()
| Default constructor. More...
| WeightedRandomIntegerGenerator (const std::vector< double > &probabilities, size_t min=0)
| 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

## ◆ WeightedRandomIntegerGenerator() [1/2]

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

Constructor.

Parameters

  probabilities | The 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.
  min | The 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.

## ◆ WeightedRandomIntegerGenerator() [2/2]

isc::util::random::WeightedRandomIntegerGenerator::WeightedRandomIntegerGenerator | ( |  | ) |
| inline

Default constructor.

Definition at line 119 of file random_number_generator.h.

## Member Function Documentation

## ◆ operator()()

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

Generate weighted random integer.

Definition at line 146 of file random_number_generator.h.

## ◆ reset()

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

Reset the probabilities.

Change the weights of each integers

Parameters

  probabilities | The probabilities for all the integers
  min | The 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:

- random_number_generator.h