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.
Datei anzeigen Open project: DanWBR/dwsim3

Public Methods

Method 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 method

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
return int

DrawLinearSearch() public method

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
return int

IndexDistribution() public method

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.