Click or drag to resize
StdRandomDiscrete Method (Int32)
Returns a random integer from the specified discrete distribution.

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static int Discrete(
	int[] frequencies
)

Parameters

frequencies
Type: SystemInt32
frequencies the frequency of occurrence of each integer

Return Value

Type: Int32
a random integer from a discrete distribution: i with probability proportional to frequencies[i]
Exceptions
ExceptionCondition
ArgumentNullException if frequencies is null
ArgumentExceptionif all array entries are 0
ArgumentExceptionif frequencies[i] is negative for any index i
ArgumentExceptionif sum of frequencies exceeds Integer.MAX_VALUE (231 - 1)
See Also