C# Класс RandomOps.IndexDistribution

A set of integers enumerated from zero and upwards that can be drawn at random according to the given probability distribution. Probabilities are assumed to sum to one. Various functions for drawing numbers are supplied with different time-complexity advantages. Thread-safe if supplied RNG's Uniform() is thread-safe.
Показать файл Открыть проект

Открытые методы

Метод Описание
DrawBinarySearch ( ) : int

Draw a random integer from {0, .., n-1} according to previously supplied probability distribution. Time-complexity is O(log(n)), where n is the length of the probabilities-array supplied to CreateIndexDistribution(). Use this function if you make repeated draws from the same set and the set-size is large.

DrawLinearSearch ( ) : int

Draw a random integer from {0, .., n-1} according to previously supplied probability distribution. Time-complexity is O(n), where n is the length of the probabilities-array supplied to CreateIndexDistribution(). Use this function if you make repeated draws from the same set and the set-size is small.

IndexDistribution ( Random rand, double probabilities )

Create the object. Time-complexity for doing this is O(n), where n is the length of the probabilities-array.

Описание методов

DrawBinarySearch() публичный Метод

Draw a random integer from {0, .., n-1} according to previously supplied probability distribution. Time-complexity is O(log(n)), where n is the length of the probabilities-array supplied to CreateIndexDistribution(). Use this function if you make repeated draws from the same set and the set-size is large.
public DrawBinarySearch ( ) : int
Результат int

DrawLinearSearch() публичный Метод

Draw a random integer from {0, .., n-1} according to previously supplied probability distribution. Time-complexity is O(n), where n is the length of the probabilities-array supplied to CreateIndexDistribution(). Use this function if you make repeated draws from the same set and the set-size is small.
public DrawLinearSearch ( ) : int
Результат int

IndexDistribution() публичный Метод

Create the object. Time-complexity for doing this is O(n), where n is the length of the probabilities-array.
public IndexDistribution ( Random rand, double probabilities )
rand Random RNG object to use.
probabilities double Probability distribution.