SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
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: 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.