generative modeling for Rhino
Most components in Grasshopper that utilize randomness on some level have an input called 'Seed'. So what is a seed for, why would you want to change it and how do you know what to change it to?
First, let's talk about randomness. Randomness is a problem in computing because digital computers are deterministic. If you give them the exact same instructions they always end up with the exact same result. It turns out to be mathematically impossible to generate true random numbers using a digital computer, but it is fairly easy to generate pseudo-random numbers. This is actually not bad news as pseudo-random numbers -unlike real random numbers- can be generated again and again and you'll end up with the same random numbers every time. Being able to get the same random numbers on demand increases the reliability of these number sequences which in turn makes them easier to use.
Pseudo-random numbers are numbers that have certain characteristics. Note that when we talk about random numbers we are really talking about numbers. Plural. It's easy to generate only a single one, as xkcd so eloquently put it:
So what are these characteristics that define pseudo-randomness? Without being actually correct, I can sum them up as follows:
There are a lot of different algorithms out there, some better than others, some faster than others, some solving very specific problems while others are more generic. The generator used in Grasshopper is the standard Microsoft .NET Random, based on Donald Knuth's subtractive algorithm.
So let's imagine we want random integers between 0 and 10. What would a bad random sequence look like?
So what about good sequences? Well, here's a few:
There are a lot of valid pseudo-random sequences. (Seriously, loads). So even if we have a good pseudo-random generator we may be given a random sequence that isn't entirely to our liking. The shorter the sequence we need, the more likely it is that statistical aberrations invalidate that particular sequence for us. What we need is some control over the generator so we don't just get a repeatable sequence, but a repeatable sequence we actually like.
Enter seed values. The random generator requires a seed value before it can generate a random sequence. These seed values are always integers, and they can be any valid 32-bit integer. Every unique seed value results in the same sequence. Every time.
Unfortunately there is no clear relationship between seeds and sequences. Changing the seed value from 5 to 6 will result in a completely difference random sequence, and two sequences that are very similar may well have to wildly different seeds. There is therefore no way to guess a good seed value, it is completely trial-and-error. Also because of this extremely discontinuous nature, you cannot use tools like Galapagos to optimize a seed value.
If you are looking for a pseudo-random sequence which has custom characteristics, you may well end up having to write your own generator algorithm. Ask questions about this on the Grasshopper main forum or the VB/C# forum.
Conclusion: Seed values are integers that define the exact sequence of pseudo-random numbers, but there's no way of knowing ahead of time what sequence it will be and there's no way of tweaking a sequence by slightly changing the seed. Even the tiniest change in seed value will result in a radically different random sequence.
* This is not actually possible. A finite amount of numbers always repeats itself eventually.
** This should only be true for long enough sequences, short sequences are allowed to cluster their values somewhat.
Interesting links for further reading:
Thank you for the explanation David.
That "S" (Seed) input within the "Random" or "Random split" components, really puzzled me.
Very interesting your explanation!
Thank you very much!