From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Achim Gratz Newsgroups: gmane.emacs.devel Subject: Re: random doesn't feel very random Date: Sat, 01 Sep 2012 09:19:04 +0200 Organization: Linux Private Site Message-ID: <87harirz13.fsf@Rainer.invalid> References: <876288yh72.fsf@kanis.fr> <87wr0livd4.fsf@Rainer.invalid> <83k3wfqtyx.fsf@gnu.org> <83vcfzosri.fsf@gnu.org> <5041626B.6080608@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1346483974 20279 80.91.229.3 (1 Sep 2012 07:19:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Sep 2012 07:19:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 01 09:19:35 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T7hzR-00079H-JI for ged-emacs-devel@m.gmane.org; Sat, 01 Sep 2012 09:19:33 +0200 Original-Received: from localhost ([::1]:57093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7hzP-0000k7-2p for ged-emacs-devel@m.gmane.org; Sat, 01 Sep 2012 03:19:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7hzL-0000jr-JG for emacs-devel@gnu.org; Sat, 01 Sep 2012 03:19:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7hzK-0002YK-6z for emacs-devel@gnu.org; Sat, 01 Sep 2012 03:19:27 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:36635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7hzJ-0002Xt-Vi for emacs-devel@gnu.org; Sat, 01 Sep 2012 03:19:26 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T7hzJ-0006wU-63 for emacs-devel@gnu.org; Sat, 01 Sep 2012 09:19:25 +0200 Original-Received: from pd9eb25b2.dip.t-dialin.net ([217.235.37.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Sep 2012 09:19:25 +0200 Original-Received: from Stromeko by pd9eb25b2.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Sep 2012 09:19:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pd9eb25b2.dip.t-dialin.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:MWa/L/CI0T63UJ9ltj9CUNL+N5g= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152926 Archived-At: 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