RANCOMB (n, k <, numcomb> ); RANCOMB (set, k <, numcomb> );
The RANCOMB function generates random combinations of k elements taken from a set of n elements. The random number seed is set by the RANDSEED subroutine .
The first argument, set, can be a scalar or a vector. If set is a scalar, the function returns indices in the range 1–n. If set is a vector, the number of elements of the vector determines n and the RANCOMB function returns elements of set.
By default, the RANCOMB function returns a single random combination with one row and k columns. If the numcomb argument is specified, the function returns a matrix with numcomb rows and k columns. Each row of the returned matrix represents a single combination.
The following statements generate five random combinations of two elements from the set :
n = 4; k = 2; call randseed(1234); c = rancomb(n, k, 5); print c;
The function can return combinations for arbitrary numerical or character matrices. For example, the following statements generate five random pairwise combinations of four elements:
d = rancomb({A B C D}, 2, 5); print d;