java.lang.Object
io.jenetics.internal.math.Subset
This class creates random subsets of size
k
from a set of n
elements. Implementation of the RANKSB
algorithm described by
Albert Nijenhuis and Herbert Wilf in Combinatorial
Algorithms for Computers and Calculators
Reference: Albert Nijenhuis, Herbert Wilf, Combinatorial Algorithms for Computers and Calculators, Second Edition, Academic Press, 1978, ISBN: 0-12-519260-6, LC: QA164.N54. Page: 42
- Since:
- 4.0
- Version:
- 7.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
next
(RandomGenerator rnd, int n, int k) Selects a random subset of sizek
from a set of sizen
.
-
Method Details
-
next
Selects a random subset of sizek
from a set of sizen
.- Parameters:
n
- the size of the set.k
- the size of the subset.rnd
- the random number generator used.- Returns:
- the a-set array for the given parameter. The returned sub-set array is sorted in increasing order.
- Throws:
NullPointerException
- ifrandom
isnull
.IllegalArgumentException
- ifn < k
,k == 0
or ifn*k
will cause an integer overflow.
-