Using the random object
The random object generates a random value from 0 to 1 less than the value specified by the argument.
The random object shows up in many tutorials and example patches. The following tutorials represent particularly useful techniques for using the object.
- It is introduced in Max Basic Tutorial 10: Random Drawing.
- Max Basic Tutorial 17: Data Structures And Probability uses random with uzi to rapidly generate values to fill up table and histo objects.
- Max Basic Tutorial 19: Timing demonstrates another common use of random, combining it with the select object to randomly choose between 4 constant values.
- Max Basic Tutorial 22: Designing Equations uses random in conjunction with the scale object to generate coefficients for use in generating equations for random drawing to an lcd.
All of the CyclistMusic patches use random in multiple places within the patches. These are a great way to get a sense of how to use the object in general and more specifically, how to incorporate randomization into timing, note selection, and other musical vocabularies.
random Tips and Workarounds
The output of random is always an integer and always outputs values from 0 to 1 less than the range specified by the argument. In many cases you will want to convert these values to floating point or to offset them in some way, whether it is to control vizzie objects, OpenGL parameters or coordinates, to generate negative values, or even just to start from 1 instead of 0. In many cases you can do this by simply re-scaling the values using a scale object or by adding an offset with the + object.
This patch shows a simple way to use the random object to create an adaptive probability system. Similar to the functionality of decide, it chooses between two possible states, however, each time one state is selected it is more likely to be selected again.
This may seem obvious, but when converting the output of random to floats, you can use large ranges to increase resolution.
Random tries to create true random numbers within its range, which means that a repeat number is just as likely as any other number. For random numbers without repetition, look at urn.
If you are working in VIZZIE and want some random behaviors, look at vz.jittr, which introduces noise into any signal (within the standard vizzie data range of 0. - 1.) and vz.wandr, which emulates the behavior of drunk (also in the 0. - 1. data range.)
Third-Party Max externals similar to the random object
People who looked at/used this object also looked at....
Errors or Clarifications
(please list things that you believe to be errors or omissions from the existing refpage)