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

SHUFFLE GROUPS

Name:
    SHUFFLE GROUPS (LET)
Type:
    Let Subcommand
Purpose:
    Given a response variable and a group-id variable, re-arrange the groups based on an index variable (the response variable is not randomized within the group).
Description:
    The motivation for this command is to allow the rows (or columns) of a matrix or image to be randomly re-arranged. The randomization can be either with replacement or without replacement (this is determined by the index variable).

    The size of the index variable should be equal to the number of groups in the group-id variable. Although this command was motivated by cases where the group sizes are equal, this is not required. If the group sizes are note equal, the output variable may not be the same length as the input variable.

Syntax:
    LET <y2> = SHUFFLE GROUPS <y> <x> <index>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y> is a response variable;
                <x> is a group-id variable;
                <index> is a variable defining the order for the groups in the output variable;
                <y2> is a response variable containing the re-arranged groups;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The response variable and group-id variable should have the same number of elements. The index variable must be the same size as the number of groups in the group-id variable.

    If there are k groups in the group-id variable, then the values in the index variable should be between 1 and k. An error will be reported if they are not.

Examples:
    LET Y2 = SHUFFLE GROUPS Y X XINDEX
Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Manipulation
Implementation Date:
    2014/07
Program:
     
    . Step 1:   Read the data
    .
    read x y
    1   1
    1   2
    1   3
    1   4
    1   5
    2  11
    2  12
    2  13
    2  14
    2  15
    3  21
    3  22
    3  23
    3  24
    3  25
    4  31
    4  32
    4  33
    4  34
    4  35
    end of data
    .
    . Step 2:   Now reshuffle the groups
    .
    let iindex = data 3  1 4  2
    let yout = shuffle groups y x iindex
    .
    . Step 3:   Print the results
    .
    set write decimals 0
    print x y yout
        
    The following output is generated
     
     ---------------------------------------------
                   X              Y           YOUT
     ---------------------------------------------
                   1              1             21
                   1              2             22
                   1              3             23
                   1              4             24
                   1              5             25
                   2             11              1
                   2             12              2
                   2             13              3
                   2             14              4
                   2             15              5
                   3             21             31
                   3             22             32
                   3             23             33
                   3             24             34
                   3             25             35
                   4             31             11
                   4             32             12
                   4             33             13
                   4             34             14
                   4             35             15
        

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 01/31/2015
Last updated: 01/31/2015

Please email comments on this WWW page to alan.heckert.gov.