[Haskell] Re: About Random Integer without IO
tatd2 at kent.ac.uk
Thu Nov 11 17:43:28 EST 2004
On 11 Nov 2004, at 22:02, karczma wrote:
> Thomas Davie writes:
>> This method unfortunately depends on having a seed first though.
> Which "this method"? Please, quote the text you are referring to
> your answer.
>> One must use a different value every time the program is started,
>> commonly time or the first few bytes from /dev/random. Any one of
>> these is going to require a monadic function to generate (i.e. it
>> must come from the environment in some way - it must change every
>> time you run the program) So while this eliminates the IO monad from
>> most of the program, it must still be initiated using it.
> I understand that you mean the seed-propagation method.
> You are *partly* right, that the same program executed several times
> generate the same sequence, if initialized identically. But there is no
> need for monads, it suffices to pass a parameter, or to read a
> initialization file each time.
> Of course, anybody, especially somebody contributing to this list has
> the right to be a nit-picker. But, if one is a *practical* user of
> random stuff, then he/she usually knows such details. Moreover, it is
> sometimes very useful to control absolutely the initialization, to be
> able to repeat the experiment, so, professionals in Monte Carlo, etc.
> rarely if ever, use time, or system-dependent (and hidden) random
> For me the initialization is a *context* problem, which I separate from
> the properties of the random generator. It is its quality, lack of
> correlations, etc. which is important. Do you know of many problems
> requiring an automated, truly random initialization? In this case one
> may well delegate this issue to the *launching* of the functional
> instead of struggling with it from within.
> This is my personal philosophy, everybody is entitled to his/hers.
While I agree that it is often useful to start your program with
different parameters each time to seed the random number generator, I
would argue that this is often inappropriate - supposing we are writing
a very simple program to roll a virtual dice. If the user finds one
input that rolls a six, they can then use this repeatedly. Reading an
initialisation file is back to the situation of using IO to generate
More information about the Haskell