bongo-devel
[Top][All Lists]
Advanced

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

[bongo-devel] 'Random' function failing to be random


From: Anthony Chaumas-Pellet
Subject: [bongo-devel] 'Random' function failing to be random
Date: Mon, 02 Apr 2007 00:50:13 +0200

Hello,

I ran Emacs three times in "full random" mode today and noticed the
selection of tracks was exactly the same in all cases (for more than
20 tracks over a playlist of 500 tracks). I normally direct
random-playback-mode, where the lack of randomness is less obvious.

The first test was done under Emacs 22.0.93 on FreeBSD, and the second
one under Emacs 22.0.95 on Debian; they were separated by a few hours.
In addition, Emacs had already run for quite a while before I started
Bongo. A third test produced the same results.

I'm not sure if the pseudo-random generator is supposed to be so
predictable. (random t) gives more random numbers, though it seems to
be updated only every second or so (this should be good enough for
Bongo, though). So, this would give the following fix:

@@ -2234,7 +2234,7 @@
 If there are no lines that satisfy PREDICATE, loop forever."
   (save-excursion
     (while (progn (goto-line (+ (point-min)
-                                (random (count-lines (point-max)
+                                (mod (random t) (count-lines (point-max)
                                                      (point-min)))))
                   (not (funcall predicate))))
     (point)))

Early testing has displayed a non-predictable behaviour in full random
mode, but I'll probably write a formal test of the random generator.
The documentation does claim that "all integers representable in Lisp
are equally likely", but.

Anthony Chaumas-Pellet




reply via email to

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