Randomisation (rand, rrand, choose)

I understand “rrand”’ uses a not-really-random list and you can change that list with “seed”.
From the tutorial, I’m not certain if “rand” is truly random or not? Same with “choose”: does it choose really random, or also pseudo-random?

All computer generated " randomness " is pseudo …
That usually suffices for music ( since it’s not like
gambling , where one might cheat if they learn
the patterns ) … : )

As far as I know, SP uses the same list of random values for all functions involving randomization. If you need ‘real’ randomness, you can use an expression like:

t = Time.now.to_i
use_random_seed t
puts rand

But actually a list of random values as the base of a randomization is very valuable, because it makes randomness repeatable (which seems to be contradictory): The assumption behind this concept is, that in a musical context you might indeed want to have some sort of randomness but once you share the code it should be the same choices as in the moment you created this randomness in the first place.

So, as far as I understand and appreciate, randomness in Sonic Pi means: Let it choose the first time and make this choice repeatable in order 1. to share and 2. to use it as creative tool.

Sonic Pi’s randomisation system is not random - it’s deterministic. This means that the same code will always produce the same sounds. This makes it possible to save your code, re-open it another time and know what it will do. You can also share code via email with a friend and know what they will hear on their computer.

For more information check out section 4 of the tutorial which covers randomisation:


Thank you all.

I am reading the tutorial, I just wasn’t sure what the difference between rand and rrand was. I thought maybe “rand” was truly random.
But the difference is the kind of numbers it returns, rrand includes 0 and rand doesn’t. Both floats.

I’m not convinced of the usefulness of this pseudorandomness, but once I start coding maybe it becomes clear. I’m sure it is well thought out :-).

Thanks again. While proceding to read the tutorial, I will come back here for questions (one question more sensible than the other).