| No. The rand function is a standard library ~algorithm~ in C (and in languages
generally), it is not any sort of object at the system or machine level
(discounting esoteric machines with hardware-based noise generation).
Output form the standard C library rand() routine is always the same, fully
determined by the particular formula used, usually the 'linear congruential'
algorithm. There is an interesting discussion of this in the book 'Numerical
recipes in C', which explains why this algorithm is not as wonderful as one
might like. It has the advantage of computational economy, however.
Most programs seed the random number generator from the system time, so that the
result is different for each execution of the program. This is exactly what
Csound does (using the library funtion srand(seed)).
So, indeed, to get a sequence of identical runs (or just to escape from the
default), any opcode which uses rand() needs to allow for a user-specified seed.
However, it is also true to say that, within a program, each call to the rand
function, from wherever, gets the next number in the sequence, so that so long
as one opcode enables seeding (even if the result is not used), that will affect
all other opcodes which call rand().
Richard Dobson
pete moss wrote:
>
> > and time is used to seed the C library's PRNG. Note that the output
> > of this PRNG could also be affected by other programs running on the
> > computer, which could be seeding the PRNG and taking numbers from it
> > - either of which would affect the numbers being returned to the
> > various points in Csound which call rand() to get pseudo random
> > numbers.
> >
>
> how is this possible? how can a function in one program call a function in
> another program, unless designed to do so? csound doesnt use a common dll for
> the rand() function does it?
>
> also, i think the seed opcode should be put in the manual, as i had the same
> problem that i discussed on the list a year ago, and just now i heard of the
> seed opcode.
>
> pete |