Dataplot Vol 2 Vol 1

# RANDOM SUBSET

Name:
RANDOM SUBSET (LET)
Type:
Let Subcommand
Purpose:
Generate a random subset.
Description:
A basic combinatorial problem is to generate the 2n subsets of the set {1, 2, ..., n}.

This command generates a single random subset among the 2n possible subsets.

The output is an array of zero and one values where zero for the ith element of the set indicates the element is not present and a value of one indicates the ith element is present. For example, if n = 5 an output array of

1 0 0 1 1

specifies that elements 1, 4, and 5 are present while elements 2 and 3 are not.

Syntax:
LET <y> = RANDOM SUBSET             FOR I = 1 1 <n>
where <n> is a number or parameter that specifies the size of the set;
and     <y> is a variable where the random subset is saved.
Examples:
LET N = 5
LET Y1 = RANDOM SUBSET FOR I = 1 1 N
Note:
Dataplot implements this command using the algorithm described in Nijenhuis and Wilf (see Reference section below).
Note:
Dataplot supports a number of different random number generators. Enter HELP RANDOM NUMBER GENERATOR for details.

The SEED command can be used to specify a seed for the random number generator.

Default:
None
Synonyms:
None
Related Commands:
 LET = Generate data transformations. RANDOM PERMUTATION = Generate a random permutation. RANDOM K-SET OF N-SET = Generate a random k-set of n-set. RANDOM COMPOSITION = Generate a random composition. RANDOM PARTITION = Generate a random partition. RANDOM EQUIVALENCE RELATION = Generate a random equivalence relation. NEXT SUBSET = Generate the next subset of a set. NEXT PERMUTATION = Generate the next permutation. NEXT K-SET OF N-SET = Generate the next k-set of n-set. NEXT COMPOSITION = Generate the next composition. NEXT PARTITION = Generate the next partition. NEXT EQUIVALENCE RELATION = Generate the next composition.
Reference:
Nijenhuis and Wilf (1978), "Combinatorial Algorithms", Second Edition, Academic Press, Chapter 2.
Applications:
Combinatorial Analysis
Implementation Date:
2008/4
Program:
```
LET N = 10
LET Y = RANDOM SUBSET FOR I =  1  1  N
PRINT Y
```

Date created: 1/12/2009
Last updated: 1/12/2009
Please email comments on this WWW page to alan.heckert@nist.gov.