[chuck-users] easy random numbers

Kassen signal.automatique at gmail.com
Wed Nov 21 15:41:50 EST 2007

On 21/11/2007, Scott Wheeler <wheeler at kde.org> wrote:
> I found the pattern -- I was using "--silent" on Windows.  Windows seems
> to use the number of milliseconds since the program started running in
> its computation of rand().  If you remove the 1::second => now from the
> loop the numbers are in fact random.  Effectively using --silent did
> that to my runs (since durations aren't respected then).  All of the
> different durations that I tried in your loop seem to produce a
> different, repeated sequence.

Ah! Good work!

Assuming the  random number generator itself is solid enough for our
purposes (sounds safe to me as a assumption, it's not that hard) this could
still be fixed by coming up with a per session initial seed for the series,
then basing every new one the last permutation right?

Interestingly this;
Noise n => blackhole;

//avoid generating a zero (perhaps done to avoid clicks, perhaps it's the
first of the series?)
ms => now;


.....Will always start with the same number (0.851436) the first time it's
run but running it multiple times while keeping the VM alive won't repeat
like rand2 will. Sadly that means Noise won't get us a free seed to start
with, which is what I was of course hoping for.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071121/6e1401e1/attachment.htm 

More information about the chuck-users mailing list