# Chapter 5Random Selection II: Statistical Frames

The typescript for chapter 5 is provided in AutomatedComposition05.pdf.

The term statistical frames is my typescript's new name for an old practice. This practice was already known as “selection without replacement”. The words “without replacement” pay deference to Jacob Bernoulli's ball-and-urn paradigm, first introduced in Chapter 4. The difference from selection “with replacement” is that balls drawn out of the urn are set aside until the urn empties out, then replenished back into the urn. (Bernoulli himself recognized both modes of selection.)

I coined the term statistical frame to describe an artifact which arises out of the method, which is the set of consecutive decisions during which the urn contents deplete to nothing.

The most familiar musical example of selection without replacement is the twelve-tone technique of Arnold Schoenberg. A basic premise of Schoenberg's technique is that all twelve degrees of the chromatic scale must be stated before any particular degree may be repeated. Thus music composed using this technique proceeds in frames of twelve notes during which the non-repetition rule is applied strictly. However, non-repetition does not apply over the ‘cusps’ (not my word) between frames: the composer is entirely free to begin a new frame with the precise degree that ended the previous frame.

The presence of these frames, and of the cusps that come between, begs musical interpretation. Should frames align with phrasing? Is there some sort of tension dynamic going on at the cusps, where the constraint against repeating a scale degree suddenly relaxes? Such questions bedeviled me when I first encountered twelve-tone technique, and I believe my own perplexity is shared almost universally among composition students.

Viewed statistically, the effect of statistical framing is clear. It produces accurate distributions.

### Synopsis

To implement the method of statistical frames requires arrays to hold the supply of distinct options (e.g. durations, dynamics, pitches), the weight associated with each option, and the pool which serves as the programmatic counterpart of the urn. The code has two phases, initialization and sampling.

##### Initialization

The initialization phase corresponds to act of populating an urn. The pool size L should be large enough to accomodate at least one instance of the least-weighted option:

L  ≥
1

 minN j=1 wj

Which expression assumes that the weights wj sum to unity. If such is not the case, then the sum of weights should appear as the numerator.

To populate the pool array, generate L driver values equally spaced between zero and unity, then use a statistical transform to conform these driver values to your desired distribution.

##### Sampling

The sampling phase excutes once for each attribute selection (e.g. to select a pitch for a note). An index indicates which pool element should next be selected; making a selection increments the index by 1 until the end of the pool is reached (the cusp). At that point the pool is shuffled randomly and the index wraps back to the beginning of the pool.

Knuth's Seminumerical Algorithms presents an algorithm for random shuffling on page 127. My “Catalog of Sequence Generators” treats the method of statistical frames on page 59, where it also reproduces the random shuffling algorithm from Knuth.

##### History

Call it statistical framing or selection without replacement, the practice is an established tradition for composing programs. The historical examples provided by Chapter 5 found publication in Automated Composition in Retrospect at the pages indicated: The pitch-selection mechanism for Herbert Brun's 1964 Sonoriferous Loops is described on p. 172. Gottfried Michael Koenig's 1970 Übung für Klavier (generated using Project Two) is described on pp. 175-178.

### Commentary

The selection model adopted in this chapter carries over once again from Gottfried Michael Koenig's Project Two. That is, the decisions pertaining to a specific musical attribute all draw from the same supply of options. Of the selection features which determine how to choose elements from the supply, two are pertinent to the present chapter:

• SERIES selects supply elements uniformly without replacement.
• RATIO assigns an integer weight to each supply element and also maintains counts detailing how many of each element remain to be selected. Initially, these counts are set equal to the corresponding weights. There are two steps to selecting an element:
1. An element is selected with nonuniform randomness, the probability of each option being determined by its associated count.
2. The count for the selected option is decremented.
These steps are repeated until all counts have been depleted, at which point the counts are replenished to the corresponding weights.
PitchE4F4G4A4B4C5D5
Probability 0.0850.1550.1740.1730.1740.1550.085
Denominator: 12 1/122/122/122/122/122/121/12
Denominator: 34 3/345/346/346/346/345/343/34
Table 1: Pitch probabilities with ratio approximations.

The commentary for Chapter 4 revealed that while random selection with replacement comes over the long term to reflect the guiding distribution, the population sizes necessary for conformance are far larger than those typically encountered by composing programs. The alternative offered by selection without replacement reproduces the guiding distribution exactly over the course of each statistical frame. However the need to keep frame lengths short precludes fine distinctions of the sort enumerated in the “Probability” row of Table 1. Rather, the method requires discrete ball counts such as those offered by Table 1's “Denominator 12” and “Denominator 34” rows.

Applying the denominator-12 row would institute the following process:

• Fill the urn with one ball marked E4, two balls marked F4, two marked G4, two marked A4, two marked B4, two marked C5, and one ball marked D5.
• To select a pitch for note #1, populate the balls into the urn and mix the balls blindly. Draw out a ball and assign the pitch name on the ball to note #1, then set the ball aside.
• To select a pitch for note #2, draw out a second ball (no need to mix) and assign the pitch name on the second ball to note #2, then set the ball aside.
• Continue in this manner assigning pitch names to note #3 through note #2. This point in the succession is called the “cusp”. At this point you've achieved the full diversity of the distribution (or rather of your approximantion by discrete ball counts) but your urn is now empty. Replace all the balls in the urn and mix blindly.
• To select a pitch for note #11, draw out a ball and assign the pitch name on the ball to note #1, then set the ball aside.
• Keep on going, replenishing the urn whenever it empties, until all notes have pitches.

I have coded a process using the method of statistical frames to select pitches according to the “Denominator 12” row of Table 1. Results from this process are presented in Table 2. The first row of this table presents a full sequence of 48 pitches with an accompanying statistical analysis. Subsequent rows analyze 12-member subsequences. Those starting in positions 0, 12, 24, and 36 align directly with the statistical frames. Unsurprisingly, their statistics conform to the “Denominator 12” row of Table 1: 1, 2, 2, 2, 2, 2, 1. The subsequences starting in positions 6, 18, and 30 bridge cusps between frames; here, conformance with the “Denominator 12” row is less agreeable. Granted, these discrepancies balance out over the longer term. Going back to the first row of Table 2, the statistics for the full sequence are precisely those indicated in the “Denominator 12” row.

Position Length Content Summary Counts Proportions Counts Proportions Counts Proportions E4 F4 G4 A4 B4 C5 D5 0 48 A4 D5 B4 F4 G4 F4 E4 C5 B4 A4 C5 G4 E4 F4 A4 B4 B4 C5 D5 G4 C5 F4 A4 G4 A4 F4 A4 G4 C5 C5 B4 G4 F4 E4 D5 B4 B4 F4 G4 E4 C5 A4 C5 D5 A4 F4 B4 G4 4 8 8 8 8 8 4 0.0833 0.167 0.167 0.167 0.167 0.167 0.0833 0 12 A4 D5 B4 F4 G4 F4 E4 C5 B4 A4 C5 G4 1 2 2 2 2 2 1 0.0833 0.167 0.167 0.167 0.167 0.167 0.0833 6 12 E4 C5 B4 A4 C5 G4|E4 F4 A4 B4 B4 C5 2 1 1 2 3 3 0 0.167 0.0833 0.0833 0.167 0.250 0.250 0 12 12 E4 F4 A4 B4 B4 C5 D5 G4 C5 F4 A4 G4 1 2 2 2 2 2 1 0.0833 0.167 0.167 0.167 0.167 0.167 0.0833 18 12 D5 G4 C5 F4 A4 G4|A4 F4 A4 G4 C5 C5 0 2 3 3 0 3 1 0 0.167 0.250 0.250 0 0.250 0.0833 24 12 A4 F4 A4 G4 C5 C5 B4 G4 F4 E4 D5 B4 1 2 2 2 2 2 1 0.0833 0.167 0.167 0.167 0.167 0.167 0.0833 30 12 B4 G4 F4 E4 D5 B4|B4 F4 G4 E4 C5 A4 2 2 2 1 3 1 1 0.167 0.167 0.167 0.0833 0.250 0.0833 0.0833 36 12 B4 F4 G4 E4 C5 A4 C5 D5 A4 F4 B4 G4 1 2 2 2 2 2 1 0.0833 0.167 0.167 0.167 0.167 0.167 0.0833
Table 2: A 48-pitch sequence generated using the weights prescribed in the “Denominator 12” row Table 1.

### Demonstration

The practical programming content of Chapter 5 was provided by Demonstration 3: Statistical Frames. The outer loop of this program employs the method of statistical frames to select attributes for phrases: phrase duration, average note duration, articulation, and central pitch. The inner loop of the program uses the method of statistical frames to select a chooser for a play-rest trial. It again uses the method of statistical frames to select an unscaled note duration (to be multiplied by the average note duration), and (for notes) a deviation around the central pitch.

 © Charles Ames Page created: 2017-03-12 Last updated: 2017-03-12