[racket] [BULK] Fundamentals

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Thu Oct 14 09:00:57 EDT 2010

On Wed, Oct 13, 2010 at 11:06:50PM -0400, Stephen Bloch wrote:
> On Oct 13, 2010, at 7:29 PM, Mathew Kurian wrote:
>> -- Is Racket an interpreted language? If not, how does it convert to 
>> machine/binary code?
> As you know, Racket evolved from Scheme, which evolved from Lisp, which 
> in its earliest implementations (fifty years ago) was interpreted rather 
> than compiled.  This has led many people to assume that ALL 
> Lisp/Scheme/Racket implementations must be interpreted rather than 
> compiled, even though that hasn't been true for decades.
>> -- In general computing, how does the random function work? How can  
>> computer language ever create random numbers, that would be  
>> impossiible?
> No, it's not impossible.  If you want truly random numbers, you attach 
> your computer to a Geiger counter, or a cosmic ray counter, or something 
> like that.  But that's expensive and slow.

There was actually a book published in the 50's or 60's with a million 
random digits that were generated in this fashion.  The CRC tables 
republished an extract out of this book.  I've always fantasized about 
seenig someone publish, as an example or "really" random numbers, some 
random numbers out of this book, whereupon I could complain, "Those 
aren't random at all.  They're just the first fifteen numbers on page 
so and so of this book I hold in my hand."  So this is the kind of 
argument that maks the definition of "random" philosohically deep.

But it's very, very useful to have a sequence of pseudo-random numbers 
that can be regenerated identically from scratch every time you run a 
program.  For example, when a program using random numbers crashes, 
you'd like to be able to run it repeatedly in a debugger and have it do 
exactly the same things every time until you narrow down the problem.

-- hendrik

>  So most "random number 
> generators" are actually completely deterministic.  For example,
> (local [(define seed 27)
>             (define (next-random limit)
>                   (begin (set! seed (remainder (+ (* seed 13) 5) 473))
>                                (remainder seed limit)))]
>    next-random)
> builds a function that "acts random": since the seed is hidden, there's 
> no obvious way of predicting the next answer from the previous answer.  
> (I just made up the numbers 27, 13, 5, and 473; in fact, there are lots 
> of research papers on how to choose such numbers to make the results as 
> random-looking as possible.)

Yeah, and these numbers aren't likely to give you a good one.  Look up 
the paper with a title something like "Random Numbers -- good ones are 
hard to get" from a decade or two ago for a good and fst one.  Or look 
up, as I mentioned elsewhere, the Mersenne Twister, which has a 
reputation of being very good, although slow.

-- hendrik

Posted on the users mailing list.