# 20Concepts Lesson 07 - More About Numbers

(Difference between revisions)

(Needed: Example Video)

(Needed: Overview Text)

## 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 chance in the arts can fall under different headings such as random, stochastic, aleatoric, or probabilistic but they all share a common theme - events which result in non-deterministic outcomes some or all of the time.

While the use of chance has been in the arts for many centuries it was not until the 20th century that the Western Art world started taking a more concerted look at the role of randomness in the arts. In music people like John Cage and Iannis Xenakis developed compositional techniques for random and probabilistic composition and performance, authors such as William Burrows experimented with cut-up techniques, Dadaist painters used various random techniques to create anti-art and later on Jackson Pollack used a mixed of intent and randomness in his Action Painting. In the contemporary arts world the use of chance is seen as a general principle that can be employed at will. In the Digital Arts the use of different random techniques is often a fundamental requirement to producing specified goals.

## Random

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.

## URN

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. Using the urn object can be thought of like putting names in a hat. 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)

• change
• clip
• rslider

(Needed: text)