20Concepts Lesson 07 - More About Numbers

From Cycling '74 Wiki
Revision as of 17:30, 28 November 2012 by grizzle (Talk | contribs)

Jump to: navigation, search

(Needed: Example Video)

(Needed: Overview Text)

(Needed: Fixture Patches with download)

Random Numbers

Random numbers are used in games, gambling, statistical analysis, music, art, randomized design, A.I., computer simulation and even divination. The use of random numbers over the ages has seen the development of many techniques to develop a random output of numbers. Examples are dice, coin flipping, shuffling or playing cards, the use of yarrow sticks in I Ching and others.

The use of random numbers, in the arts at least, can have many different names. It can be called random, stochastic, aleatoric, probabilistic but they all generally fall under the heading of non-deterministic outcomes. Compositions that could be considered a precedent for aleatory composition date back to at least the late 15th century, with the genre of the catholicon, exemplified by the Missa cuiusvis toni of Johannes Ockeghem. A later genre was the Musikalisches Würfelspiel or musical dice game, popular in the late 18th and early 19th century. The term aleatory music was first coined by Werner Meyer-Eppler in 1955 to describe a course of sound events that is "determined in general but depends on chance in detail". American composer John Cage's Music of Changes (1951) is often considered the first piece to be conceived largely through random procedure, although it differed in details from Werner Meyer-Epplers description. The modern use of random numbers in music has become a widespread and commonly practiced technique.


In Max there are many ways to generate random numbers but there are a few objects dedicated to providing this function. Random, Drunk, Urn and Decide are four objects commonly used to generate a random stream of numbers or to make decisions randomly.

The Random object takes a maximum number as a argument. When the Random object is sent a Bang it will output a number between 0 and the maximum. For example when banged a random object with an argument of 100 will output a number between 0 and 99. An integer number box connected to the right inlet of the random object allows the user to set the maximum argument at a later time.

The random object only outputs integers or whole numbers so we need to further divide the output by a floating point number to get fractional numbers. For example to get a random value between 0. and 1. a typical practice would be to generate a random number with a maximum of 1000 and then divide the output by 1000.00 floating point. The result will now be a random number between 0. and 1. with 3 decimal places or ranging between 0.000 and 0.999.

A typical musical use of the random object is to randomly generate sequences of numbers between 0 and 127 which are then sent to the makenote object or the mtof object to generate pitched tones. Another typical use might be to randomly generate values for synthesis parameters.


When using the Random object every number between 0 and the set maximum has an equal probability of being generated. This means that it is possible for numbers to repeat. While this is truly random it is not always useful in an artistic setting. We may not mind what value is output, given a certain range, but we do want a different value not the same value repeated again.

To meet this requirement use the urn object. Urn can be thought of like names in a hats. After a name is randomly chosen it is also removed from the hat. This prevents the possibility of repeating the same value. When urn has exhausted all it's possibilities it needs to be reset - which is the digital equivalent of putting the names back in the hat.

It can happen that after urn has been reset the next number out of the newly reset urn can be the same as the last number from the last round of randomly generated numbers. To remove all possibility of ever having a value directly repeat use the urn-jb abstraction. Urn-jb solves this problem by shifting the new series by one, if necessary.


(Needed: text)


(Needed: text)

Filtering Repetitions and Defining Boundaries

  • change
  • clip
  • rslider

(Needed: text)

Web Links

(Needed: text and links)


(Needed: text and exercises)

by Darwin Grosse and Cory Metcalf