Randomness

Some people just want to see the world burn and watch as society descend into chaos. For these kinds of people there are random functions. Sometimes you might want things to happen randomly, or semi-randomly. We have a few nodes for that.


Random

This seems like an obvious place to start. The random node will output a random value when triggered. The node has two modes of operation set in the inspector: Uniform and Normal.


Uniform

In the default uniform node you can set a min and max range. The number generated will be in this range.


Normal

In normal mode the random value is determined over a bell curve. This is called importance sampling using normal distribution. How this precisely works is way out of the scope of this article, but we’re here to teach you how to work with it.

First we set a mean, this is your average value. By default this is 0. Next we set our deviation, this is the standard deviation of the mean. By default this is 1.

Because we use a bell curve to create a random value, there is a 68.2% chance that our random value will be between -1 and 1 (the standard deviation). There is a 27.5% chance that our value will be between -1 and -2 or 1 and 2. And a 0.2% chance that the value will be larger than 3 or smaller than -3.

So is there a chance that your value will be -1000 ?
Yes.
Is this likely?
Winning the jackpot is more likely.







Regardless of the mode you are using, there will be two other variables (hidden by default). Precision will determine the amount of decimals the generated number will have. Random Seed will define the seed used for generating a value.


Random Seed

Computers can do great many things, but generating true random numbers ain’t one of them.

Random values are generated by doing a series of calculations. These calculations need to be based on some value. This is what a random seed does. It is the starting point for the random calculation.


By default the seed is set to 0. Which in this ain’t really 0, we’re cheating. When set to 0 the seed will be something that is continually changing. Like the sum of the current time and date on your computer. This will be the closest to true randomness you will get.


But what if you want a random result, but always the same result. This is where manually inputting a random seed comes into play. Let's say we create two random nodes. Both with their seed set to 1. Trigger them both and you will see that they produce the same random values over and over again.

When you save your patch the seed is saved too and you’ll be able to create the same pattern of random values over and over again. Not so random anymore huh?


The purple triangles have the same seed and therefore move to the same Y-position.

Digital Noise

The Random node works with an Event flow. But you might want to create a continuous stream of random values, let's call it digital noise. There are a few ways you can do this. First we need a continuous stream of data. For this we can use an oscillator or system time. Next we use the on change node to switch from signal to event flow and we feed this into the Random node.


Random Arrays

Randomness can be used with single values as well as with arrays. To create a random array simply increase the amount of instances in the node inspector. Each value in the array will be random.

Keep in mind that if you use a custom seed that all the values in the array will be the same value due to the seed. If you need an array and a custom seed you will need to create separate nodes and turn them into an array by using the Join node.

Bag

Bag is a node that can be best described by visual storytelling. Imagine you have a bag in which you put a set of integers. Now pull those numbers out one at a time at random. When you’re done, put all the numbers back and start over. Now you know how the Bag node works!

You use the min and max values to set up the range of values that are in the bag. You send in a trigger to have the bag output a value. You can also use a trigger to reset the bag, putting all the values back in.

Shuffle

Shuffle can be used to randomize your arrays. You input an array of values and shuffle will shuffle them around. You can send in a trigger to reshuffle as many times as you like.

Hidden away in the inspector/visibility tab is the option to have duplicates. This is off by default as it creates a true shuffle. When duplicates are on you might end up with the same value multiple times.

Static

Back in the old days of analog television and CRT monitors static noise was truly a random phenomenon generated by thermal noise from within the transistors in the device.

Nowadays, like Pamela's boobies, everything is fake and we use code to simulate static noise. 

Simply input a modulation source into the time inlet to create static noise. In the inspector window you can select between grey scale, two-tone or colored noise.


Fractal Noise

Fractal noise is way more fancy than static noise and a backbone for creating generative and evolving visuals. But this is a bit more complicated and this is why we’ve dedicated a whole article to just his node. If you are into generative visuals this is a mustread.

Image generated with Fractal Noise.

Related Articles