[Haskell-cafe] Re: [Haskell] Re: About Random Integer without IO

Georg Martius mai99dgf at studserv.uni-leipzig.de
Fri Nov 12 04:55:50 EST 2004


Hi,

Sorry, but I don't really get the point of the discussion so far. I think any  computation should be done in pure functional style, that gets a random generator (seed) and passes it around. Your program starts in the IO monad anyway, so you have the choice of using newStdGen to get a new seed or initialise it by hand from a command line argument or whatever.

I think automatic random initialisation is very important and handy in programs that run non-deterministic simulations.

Cheers,
  Georg

On Thu, 11 Nov 2004 22:43:28 +0000, Thomas Davie <tatd2 at kent.ac.uk> wrote:

> 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
>> *before*
>> 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
>> will
>> generate the same sequence, if initialized identically. But there is no
>> need for monads, it suffices to pass a parameter, or to read a
>> different
>> 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
>> values.
>> 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
>> program,
>> 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
> our seed.
>
> Thanks
>
> Tom Davie
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>



-- 

---- Georg Martius,  Tel: (+49 34297) 89434 ----
------- http://www.flexman.homeip.net ---------


More information about the Haskell-Cafe mailing list