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.
파일 보기 프로젝트 열기: DanWBR/dwsim3

공개 메소드들

메소드 설명
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.