C# Class 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.
Afficher le fichier Open project: DanWBR/dwsim3

Méthodes publiques

Méthode Description
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.

Method Details

DrawBinarySearch() public méthode

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
Résultat int

DrawLinearSearch() public méthode

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
Résultat int

IndexDistribution() public méthode

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.