CombinatoricsGeneratePermutation Method |
Generate a random permutation, without repetition, by generating the index numbers 0 to N-1 and shuffle them randomly.
Implemented using Fisher-Yates Shuffling.
Namespace: Altaxo.CalcAssembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax public static int[] GeneratePermutation(
int n,
Random randomSource = null
)
Parameters
- n Int32
- Number of (distinguishable) elements in the set.
- randomSource Random (Optional)
- The random number generator to use. Optional; the default random source will be used if null.
Return Value
Int32An array of length
N that contains (in any order) the integers of the interval
[0, N).
See Also