Here are some basic combinatorial functions.
Random subsets and random tuples:
RandomSubsetIndices(n) -- returns a random subset of {0,1,2...,n-1}
RandomSubsetIndices(n,r) -- returns a size r random subset of {0,1,2...,n-1}
RandomTupleIndices(n,r) -- returns a random r-tuple from {0,1,2,...,n-1}
Notes:
- the parameter n indicates the range {0,1,2,...,n-1} so that
the integers produced are valid indices into a C++ vector of size n.
- the result is of type vector<long>
- the sampling is from a uniform distribution
The algorithm for RandomSubsetIndices(n,r) was taken from the
Wikipedia page on "Reservoir Sorting".
Ugly fn names RandomSubsetIndices and RandomTupleIndices
2015