20Concepts Lesson 07  More About Numbers
(→Drunk) 
(→Web Links) 

Line 58:  Line 58:  
== ''Web Links'' ==  == ''Web Links'' ==  
−  +  [http://algorithmiccomposer.com/ Algorithmic Composer Blog]  
== ''Exercises'' ==  == ''Exercises'' == 
Revision as of 21:25, 5 December 2012

(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 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 nondeterministic 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 cutup techniques, Dadaist painters used various random techniques to create antiart 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 urnjb abstraction. Urnjb solves this problem by shifting the new series by one, if necessary.
Drunk
The drunk object outputs what is called a random walk or a drunkard's walk. As far as I know this is a first order or simple Markov chain. Drunk takes two arguments the first being the maximum number that can be output and second the step size between consecutive numbers. For example if the drunk object has the arguments 100 and 5 then the first number output will be a random number between 0 and 99 and all subsequent numbers will be within 5 numbers +/ of the last number output.
This is useful if you need a random meandering path rather than big random jumps. A typical use would be to give drunk a maximum argument of 24 and a step size of 3 or 4 and then connect it to a MIDI output. The result will be numbers going up and down two octaves with step size no greater than three, kind of like playing runs on a piano. If you quantize the note numbers with a musical scaler it can be quite effective as a tool for simple modal improvisation.
Scaling
(Needed: text)
Filtering Repetitions and Defining Boundaries
 change
 clip
 rslider
(Needed: text)
Web Links
Exercises
(Needed: text and exercises)
by Darwin Grosse and Cory Metcalf