Random numbers (fwd)

Rex L. Page rlpage@alonzo.uoknor.edu
Tue, 12 Dec 1995 15:55:55 -0600 (CST)


Some issues regarding pseudo-random number generation
and usage are explained in 

  Burton and Page, Distributed random number generation,
  Journal of Functional Programming 2, 2 (April 1992) 203-212

Rex Page



Forwarded message:
> From clean-request@cs.kun.nl Tue Dec 12 15:19 CST 1995
> Resent-Date: Tue, 12 Dec 1995 21:50:27 +0100
> From: "Jan Krynicky" <JKRY3025@barbora.mff.cuni.cz>
> Organization:  MFF, Charles University, Prague
> 
> > Subject: Re: Random numbers
> > From: Torsten Will <itwill@TechFak.Uni-Bielefeld.DE>
> > 
> > Hello,
> > 
> > > How I get a random number in Clean?
> > 
> > In a purely functional language it is impossible to get real random
> > numbers. But there are two possibilies to solve this problem:
> > 
> > 1. Use a unique type for a random-generating function, but I don`t
> >    know how to do this.
> > 
> > 2. For some problems it is enough to generate pseudo-random numbers
> >    (numbers that SEEMS to be random, but are reproducable).
> >    In MIRANDA I write a function like that:
> > 
> > //////////////  Very simple program for generating pseudo random numbers
> > // Miranda-script
> > // pseudoRands gives a list of pseudo-randoms between 1..10
> > 
> > startvalue :: num                // num is like 'int' in C
> > startvalue = 42
> > 
> The problem is here, where to get the initial state ?
> I'd need a little help from Clean.
> 
> // Something like 
> getIniState::*WORLD -> (Int,*WORLD)
> // would be sufficient.
> 
> > 
> > Tschau, Torsten.
> > 
> 
> As someone wrote in comp.lang.functional, this explicit state passing
> style is sometimes making it too linear.
> 
> The best for applications I don't need the 'pseudo-random' features
> would be something like a standard function (variable).
> :   rand::Rand   // not unique!
> and 
> :   instance toReal Rand
> :   instance toInt  Rand
> ...
> where the rand would be weird in that, that it would be evaluated to
> different real/int/... numbers.
> 
> But it can (I think) be done only by the developers of the compiler.
> 
> \v Cau, Jenda
> 
>