[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] Randomisation
On Mon, 1 Feb 1999, daedalus wrote:
> I've heard tell of generators which read the system things like space
> between interrupts (keyboard etc) and small variations in the system
> clock ticks to try to randomise the values a little more. I suggest a
> quick look on the web for stuff on pseudo-random number generators and
> check out how big their sequences are.
Or measure the electrical noise from system components?
> "If you want to generate a random integer between 1
> and 10, you should always do it by
>
> j=1+(int) (10.0*rand()/(RAND_MAX+1.0));
>
> and never by anything resembling
>
> j=1+((int) (1000000.0*rand()) % 10);
>
> (which uses lower-order bits)."
In both cases, depending on the RNG, you could overflow first. (But not
a problem with the standard unix rand().)
Peter
------------------------------------------------------------------------
Peter Meric pmeric@nospam.cs.usyd.edu.au
pmeric@nospam.progsoc.uts.edu.au
http://www.progsoc.uts.edu.au/~pmeric
--
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.
This list is archived at <http://www.progsoc.uts.edu.au/lists/progsoc/>