emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: random doesn't feel very random


From: Achim Gratz
Subject: Re: random doesn't feel very random
Date: Sat, 01 Sep 2012 09:19:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Paul Eggert writes:
> I committed something to do that, in trunk bzr 109833 and
> 109834.

Thank you.  On systems having a better source of entropy (like
/dev/urandom), the init value should be taken from that source rather
than the "mix PID with current time" hack.

> One thing that wasn't discussed was how to set the
> seed, for people who want to do debugging and who want
> repeatable random sequences.

I don't think it's a good idea to be able to change the global PRNG
state in general.  So the (random "S") interface should be a NOP (just
like `(random t)ยด now is) unless debugging is on.  Since you would
likely want to control the initial state as well, this should probably
be controlled by a new commandline option that also allows to set the
initial state (or fall back to always using the same "magic" initial
state if none is provided).

I still think the cleanest way would be to allow packages to have a
private PRNG state bound to a variable and then each call to (random)
will advance the private state rather than the global one.  This would
require to use nrand48 instead of lrand48 or setstate (for old random),
so this might have portability implications.  For debugging the global
PRNG state could be made accessible in this case.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]