Dataplot Vol 2 Vol 1

RANDOM COMPOSITION

Name:
RANDOM COMPOSITION (LET)
Type:
Let Subcommand
Purpose:
Generate a random composition.
Description:
Given positive integers n and k, a composition of n into k parts is defined as

n = r1 + r2 + ... + rk             (ri ≥ 0, i = 1, k)

The number of compositions is given by

This command generates a single random composition.

The output is an array of size k.

Syntax:
LET <y> = RANDOM COMPOSITION             FOR I = 1 1 <k>
where <k> is a number or parameter that specifies the size of the composition;
and     <y> is a variable where the random composition is saved.

This command must be preceeded with the command

LET N = <value>
Examples:
LET N = 5
LET K = 3
LET Y = RANDOM COMPOSITION FOR I = 1 1 K
Note:
Dataplot implements this command using the RANCOM 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 PARTITION = Generate a random partition. RANDOM SUBSET = Generate a random subset. 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 6.
Applications:
Combinatorial Analysis
Implementation Date:
2008/4
Program:
```
LET N = 8
LET K = 3
LET Y = RANDOM COMPOSITION FOR I =  1  1  K
PRINT Y
```

Date created: 1/12/2009
Last updated: 1/12/2009