if we use a random seed, f.e. Std.srand(120); will this affect all the random function inside the sketch? and if so, how can we turn it off? thanks
On 9 Sep 2010, at 20:49, Lars Ullrich wrote:
if we use a random seed, f.e. Std.srand(120);
will this affect all the random function inside the sketch? and if so, how can we turn it off?
You do not have to seed - looking into the source code, if the seed is not given, time will be used as seed.
Hi Lars! if we use a random seed, f.e. Std.srand(120);
will this affect all the random function inside the sketch?
Yes, it will. And this does mean that periodically resetting the seed (say at audio-rate) will turn the UGens that use noise into a sort of wavetable players; it will affect all random functions and noise-generators.
and if so, how can we turn it off?
Well, you can't. The whole point of ,srand() is affecting the various random functions to create repeatable pieces. A alternative would be simply not setting it, though I do seem to remember some issues with the initial seed under Windows not being particularly random. In that case you could set the seed using a amplified signal from the adc. A source like hiss from your mixer should be as random a signal as you are likely to encounter in day to day life and mak things utterly unpredictable. Hope that helps, Kas.
Hi Kassen & Hans, That's very sad! A seed is perfect to get a repeating pattern, but sometimes it's nice to turn off the seed to get non repeatable values. So the only way is to delete the seed and restart the sketch? thanks! Am 10.09.2010 um 01:53 schrieb Kassen:
Hi Lars!
if we use a random seed, f.e. Std.srand(120);
will this affect all the random function inside the sketch?
Yes, it will. And this does mean that periodically resetting the seed (say at audio-rate) will turn the UGens that use noise into a sort of wavetable players; it will affect all random functions and noise-generators.
and if so, how can we turn it off?
Well, you can't. The whole point of ,srand() is affecting the various random functions to create repeatable pieces.
A alternative would be simply not setting it, though I do seem to remember some issues with the initial seed under Windows not being particularly random. In that case you could set the seed using a amplified signal from the adc. A source like hiss from your mixer should be as random a signal as you are likely to encounter in day to day life and mak things utterly unpredictable.
Hope that helps, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 9 Sep 2010, at 20:49, Lars Ullrich wrote:
if we use a random seed, f.e. Std.srand(120);
will this affect all the random function inside the sketch? and if so, how can we turn it off?
You do not have to seed - looking into the source code, if the seed is not given, time will be used as seed.
So the only way is to delete the seed and restart the sketch? Short answer; "no". Long answer; a PRNG (pseudo random number generator) typically consists of a number and a function. The function is set loose on
Hey, Lars, Let me address your points in reverse order; the number and the outcome becomes the new number and is returned as the random value. Sometimes only part of the number, like the least significant bits are returned. It follows that these functions must make sure this series of numbers takes a long time before they repeat, that the "seed" simply determines at what part of the cycle we start and that talking about "deleting the seed" doesn't actually make a lot of sense.
That's very sad! A seed is perfect to get a repeating pattern, but sometimes it's nice to turn off the seed to get non repeatable values.
I'm not sure whether this is "sad"... it's simply a fact of life in computer science. The numbers are never really random and *if you knew the seed* they are easy to repeat. They just look random and for a decent PRNG it should be very hard to figure out what the seed was. This might be so hard that we'd all be gone by the time some process determines it.
So; in practice this difference between repeatable numbers and truly random ones shouldn't matter too much. On the other side; it may very well be that something went wrong in the case of ChucK? Yours, Kas.
Hi Kas, I was looking for a message to turn off the seed. Something like "set seed to 0" and get non repeatable structures. (like maxmsp object lp.tata from peter castine ) Anyway, I have found a method to do this with some functions. Thanks a lot for your patience. Lars Am 11.09.2010 um 08:19 schrieb Kassen:
Hey, Lars,
Let me address your points in reverse order;
So the only way is to delete the seed and restart the sketch?
Short answer; "no". Long answer; a PRNG (pseudo random number generator) typically consists of a number and a function. The function is set loose on the number and the outcome becomes the new number and is returned as the random value. Sometimes only part of the number, like the least significant bits are returned.
It follows that these functions must make sure this series of numbers takes a long time before they repeat, that the "seed" simply determines at what part of the cycle we start and that talking about "deleting the seed" doesn't actually make a lot of sense.
That's very sad! A seed is perfect to get a repeating pattern, but sometimes it's nice to turn off the seed to get non repeatable values.
I'm not sure whether this is "sad"... it's simply a fact of life in computer science. The numbers are never really random and *if you knew the seed* they are easy to repeat. They just look random and for a decent PRNG it should be very hard to figure out what the seed was. This might be so hard that we'd all be gone by the time some process determines it.
So; in practice this difference between repeatable numbers and truly random ones shouldn't matter too much.
On the other side; it may very well be that something went wrong in the case of ChucK?
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 11 September 2010 15:31, Lars Ullrich
Hi Kas,
Hey, Lars!
I was looking for a message to turn off the seed. Something like "set seed to 0" and get non repeatable structures. (like maxmsp object lp.tata from peter castine )
The default situation should be getting a initial seed from the host OS when the VM starts. That seed should be unknown to you, but it's still a seed. There really is no way to "turn off the seed" with PRNG's. Sorry; it's not my fault ;¬).
Anyway, I have found a method to do this with some functions.
Thanks a lot for your patience.
No problem, that's what the list is for,
Yours, Kas.
This thread has made me thoroughly confused. I see that you have solved your
issue, Lars, but I would still like to know what your task was. :) I feel it
might be good for inspiration.
In my world of computer science, if you use a random generator, pretend that
you've never heard the word "seed", and just start reading random numbers,
you will effectively get non repeatable structures, different every time.
/Stefan
2010/9/11 Kassen
On 11 September 2010 15:31, Lars Ullrich
wrote: Hi Kas,
Hey, Lars!
I was looking for a message to turn off the seed. Something like "set seed to 0" and get non repeatable structures. (like maxmsp object lp.tata from peter castine )
The default situation should be getting a initial seed from the host OS when the VM starts. That seed should be unknown to you, but it's still a seed. There really is no way to "turn off the seed" with PRNG's. Sorry; it's not my fault ;¬).
Anyway, I have found a method to do this with some functions.
Thanks a lot for your patience.
No problem, that's what the list is for,
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos!
Hi Stefan,
I like to use a seed in many tasks, specialy for sequencing.
Maybe this example helps you to understand what I mean:
Std.srand(1200); //set your seed
int SeedArray[8];
//fill your array with random numbers
fun void CalcRndArray()
{
for(int i; i < SeedArray.cap(); i++)
{
Std.rand2( 1 , 1000 )=>SeedArray[i];
}
} CalcRndArray();
while (1)
{
for(int i; i < SeedArray.cap(); i++)
{
<<
This thread has made me thoroughly confused. I see that you have solved your issue, Lars, but I would still like to know what your task was. :) I feel it might be good for inspiration.
In my world of computer science, if you use a random generator, pretend that you've never heard the word "seed", and just start reading random numbers, you will effectively get non repeatable structures, different every time.
/Stefan
2010/9/11 Kassen
On 11 September 2010 15:31, Lars Ullrich
wrote: Hi Kas, Hey, Lars!
I was looking for a message to turn off the seed. Something like "set seed to 0" and get non repeatable structures. (like maxmsp object lp.tata from peter castine )
The default situation should be getting a initial seed from the host OS when the VM starts. That seed should be unknown to you, but it's still a seed. There really is no way to "turn off the seed" with PRNG's. Sorry; it's not my fault ;¬).
Anyway, I have found a method to do this with some functions.
Thanks a lot for your patience.
No problem, that's what the list is for,
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos! _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hey, Lars! I'm not Stephan, but I'm still a bit confused as well so I thought I'd answer anyway. Std.srand(1200); //set your seed
Looks fine <<<"--------------", "we always get the same numbers" >>>;
That's what we'd expect, yes.
Hope this helps!
Well.... no, not really.
What happens if you don't set the seed with srand(), do you still get the same numbers? As I understand things now you should get exactly what you are looking for by simply not setting the seed in line 1. Could you verify that by not setting the seed at all you get different numbers each time you run your program? If not we have a bug. I seem to remember there was a issue like that on Windows, which might be caused by Windows (last time I looked) not having the "storage" of OS-event based random numbers that Unix typically uses; that might be the cause. That's no excuse though; as we are not trying to secure nuclear missiles (I hope!) something like the time in ms should yield a perfectly serviceable seed at VM startup. Yours, Kas.
Gotcha! Or at least, I can see a flaw here in ChucK's randomizers: there is
only one of them! My immediate reaction to seeing your code was that it
ought to be simplified to this:
while (1)
{
Std.srand(1200); //set your seed
for(0 => int i; i < 8; i++)
{
<<
Hey, Lars!
I'm not Stephan, but I'm still a bit confused as well so I thought I'd answer anyway.
Std.srand(1200); //set your seed
Looks fine
<<<"--------------", "we always get the same numbers" >>>;
That's what we'd expect, yes.
Hope this helps!
Well.... no, not really.
What happens if you don't set the seed with srand(), do you still get the same numbers? As I understand things now you should get exactly what you are looking for by simply not setting the seed in line 1. Could you verify that by not setting the seed at all you get different numbers each time you run your program? If not we have a bug. I seem to remember there was a issue like that on Windows, which might be caused by Windows (last time I looked) not having the "storage" of OS-event based random numbers that Unix typically uses; that might be the cause. That's no excuse though; as we are not trying to secure nuclear missiles (I hope!) something like the time in ms should yield a perfectly serviceable seed at VM startup.
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos!
2010/9/11 Stefan Blixt
Gotcha! Or at least, I can see a flaw here in ChucK's randomizers: there is only one of them!
That's not really a flaw; everything random, including the Std.rand* functions, all UGen noise sources and all noisy components of STK instruments depend on the same PRNG. I looked at the source back when I was obsessed with audio-rate resetting of the seed. This means that pieces with a set seed will be perfectly and sample-accurately be reproducible. CSound has always taken that into account, as well as backwards compatibility, which means that we can now listen to CSound pieces composed decades ago using modern converters for exact accuracy. This is a non-trivial feature from a "serious computer music" point of view. What we can do is implement our own PRNG in ChucK. Random number generators have been under a LOT of analysis as cryptographic security and thus banking and government secrets depend on them. To facilitate this PRNG of a strength way beyond our needs are open and free. For a more music-based look at it all I can't recommend "A Look at random Numbers, Noise and Chaos with Csound" by John Ffitch in the CSound handbook highly enough. Sadly I can't quickly find a online version; you may be more lucky or a local library might (should!) have the book. Yours, Kas.
Let me add to the confusion (but it's really not so complicated): A: If you want "random" behavior: do nothing. The random number generator is seeded with the time of day. B: If you want repeatable random numbers (i.e., you want to get the same sequence of numbers each time you run the program), then call srand() with the number of your choosing. ... and shoot me if I've gotten that wrong. I haven't loaded ChucK onto my new laptop to verify this.
Sorry if I'm just acting like my head is made of wood, but 1: why would
anyone want to reproduce a chuck program sample-accurately? and 2: if
reproducing something sample-accurately is important to you, you can still
accomplish that by having a single global randomizer in your program
(seeded), and use that one.
/Stefan
2010/9/11 Kassen
2010/9/11 Stefan Blixt
Gotcha! Or at least, I can see a flaw here in ChucK's randomizers: there is
only one of them!
That's not really a flaw; everything random, including the Std.rand* functions, all UGen noise sources and all noisy components of STK instruments depend on the same PRNG. I looked at the source back when I was obsessed with audio-rate resetting of the seed. This means that pieces with a set seed will be perfectly and sample-accurately be reproducible. CSound has always taken that into account, as well as backwards compatibility, which means that we can now listen to CSound pieces composed decades ago using modern converters for exact accuracy.
This is a non-trivial feature from a "serious computer music" point of view.
What we can do is implement our own PRNG in ChucK. Random number generators have been under a LOT of analysis as cryptographic security and thus banking and government secrets depend on them. To facilitate this PRNG of a strength way beyond our needs are open and free.
For a more music-based look at it all I can't recommend "A Look at random Numbers, Noise and Chaos with Csound" by John Ffitch in the CSound handbook highly enough. Sadly I can't quickly find a online version; you may be more lucky or a local library might (should!) have the book.
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos!
On 11 Sep 2010, at 22:37, Stefan Blixt wrote:
Sorry if I'm just acting like my head is made of wood, but 1: why would anyone want to reproduce a chuck program sample-accurately?
One application is if one is experimenting with different parameters in combination with randomizers to produce different kinds of sounds, and then want to select a cool combination. With THX Deep Note they did not do so, resulting only having the recording. http://musicthing.blogspot.com/2005/05/tiny-music-makers-pt-3-thx-sound.html
Yeah sorry, I didn't think that one through - I can see why someone wants to
reproduce a particular sound sample-perfect. My 2 still holds though.
I think reproduction would even be better facilitated by having to instance
a randomizer before using it. If you made a sound based on random values and
you want to add stuff, today there is a risk that the new stuff will mess up
the old stuff, stealing values from the random sequence. If each thing has
its own randomizer, you don't have this problem.
/Stefan
On Sat, Sep 11, 2010 at 11:58 PM, Hans Aberg
On 11 Sep 2010, at 22:37, Stefan Blixt wrote:
Sorry if I'm just acting like my head is made of wood, but 1: why would
anyone want to reproduce a chuck program sample-accurately?
One application is if one is experimenting with different parameters in combination with randomizers to produce different kinds of sounds, and then want to select a cool combination. With THX Deep Note they did not do so, resulting only having the recording.
http://musicthing.blogspot.com/2005/05/tiny-music-makers-pt-3-thx-sound.html
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos!
What happens if you don't set the seed with srand(), do you still get the same numbers?
No.
Could you verify that by not setting the seed at all you get different numbers each time you run your program?
I get different numbers. I think there is no bug, everything works like expected.. (for me) By the way, I've noticed that Std.srand dont like double integers..
Was it something like this that you ran into, Lars?
mmm.. sorry Stefan, but I'm not sure what you mean? I was looking for a way to put off the seed and get to the normal "random mode". Now I'm using a function Std.rand2(1,1000)=>int NewSeed and then I jump back to my stored seed, like in your code. Lars Am 11.09.2010 um 18:21 schrieb Stefan Blixt:
Gotcha! Or at least, I can see a flaw here in ChucK's randomizers: there is only one of them! My immediate reaction to seeing your code was that it ought to be simplified to this:
while (1) { Std.srand(1200); //set your seed for(0 => int i; i < 8; i++) { <<
>>; } <<<"--------------", "we always get the same numbers" >>>; 2::second=>now; }
But this won't work if you use the randomizer elsewhere in your code. if someone calls Std.rand2() before the loop above has finished, the random sequence will be corrupted. It will work here though, since there is no wait statement inside the for loop, but I suspect Lars's code is more complicated than this.
Other programming languages will usually have some kind of randomizer object (e.g. "Random" in Java or the result of the seed function in PovRAY), that you instantiate with a seed (if you want) and then use independent from other random instances. If we had that you could write this code:
0 => int resetSeed; Std.makeRandomizer() => Random r; while (1) { if (resetSeed) { r.srand(1200); //set your seed } for(0 => int i; i < 8; i++) { <<
>>; } <<<"--------------", "we always get the same numbers" >>>; 2::second=>now; }
...without clashing with other usage of randomizers (I made up some function and class names).
Was it something like this that you ran into, Lars?
/Stefan 2010/9/11 Kassen
Hey, Lars! I'm not Stephan, but I'm still a bit confused as well so I thought I'd answer anyway.
Std.srand(1200); //set your seed
Looks fine
<<<"--------------", "we always get the same numbers" >>>;
That's what we'd expect, yes.
Hope this helps!
Well.... no, not really.
What happens if you don't set the seed with srand(), do you still get the same numbers? As I understand things now you should get exactly what you are looking for by simply not setting the seed in line 1. Could you verify that by not setting the seed at all you get different numbers each time you run your program? If not we have a bug. I seem to remember there was a issue like that on Windows, which might be caused by Windows (last time I looked) not having the "storage" of OS-event based random numbers that Unix typically uses; that might be the cause. That's no excuse though; as we are not trying to secure nuclear missiles (I hope!) something like the time in ms should yield a perfectly serviceable seed at VM startup.
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the Cosmos! _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
I get different numbers. I think there is no bug, everything works like expected.. (for me)
Great! And you can still accomplish what you'd like to do, I hope? Crisis averted?
By the way, I've noticed that Std.srand dont like double integers..
Could you be a bit more specific? This sounds like there might be a real
issue after all. Kas.
And you can still accomplish what you'd like to do, I hope?
yes! everything is fine. thanks
Could you be a bit more specific?
sorry, I meant Std.rand.
can you run this code please:
while(1)
{
<<
I get different numbers. I think there is no bug, everything works like expected.. (for me)
Great! And you can still accomplish what you'd like to do, I hope? Crisis averted?
By the way, I've noticed that Std.srand dont like double integers..
Could you be a bit more specific? This sounds like there might be a real issue after all.
Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Hans Aberg
-
Kassen
-
Lars Ullrich
-
Robert Poor
-
Stefan Blixt