[Top][All Lists]

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

Re: random doesn't feel very random, random doesn't feel very random, Re

From: Ivan Kanis
Subject: Re: random doesn't feel very random, random doesn't feel very random, Re: random doesn't feel very random
Date: Fri, 24 Aug 2012 19:19:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Tassilo Horn <address@hidden> wrote:

> You can test it at least.  Some methods are discussed here.
>   http://www.johndcook.com/Beautiful_Testing_ch10.pdf

Thanks I'll look if I find the time and the inclination.

"Stephen J. Turnbull" <address@hidden> wrote:

> To avoid this behavior, use `(random t)'

I do.

> I hope your life doesn't depend on the secrecy of your playlist,
> though. :-)

Nope ;)

> If it always plays tracks from the same subset of your collection, but
> in different orders, you may have made a programming error.

It sort of does that. Here's the function that picks music up. I have
attached the rest of the code if you'd like to see more.

(defun ivan-emms-pick-album (dir length with-cache)
  "Return a LENGTH albums in a directory DIR.
If WITH-CACHE is non-nil exclude albums that are in cache."
  (let* ((index 0)
         (ret (make-vector length nil))
         (album (ivan-emms-list-subdir
                 (concat ivan-emms-dir dir)))
         (album-length (length album))
    (when with-cache
      (setq ring (ivan-emms-last-load)))
    (while (< index length)
      (aset ret index
            (nth (if with-cache
                     (let* ((r (random album-length))
                            (album (nth r album)))
                       (while (ring-member ring r)
                         (setq r (random album-length)
                               album (nth r album)))
                       (ring-insert ring album)
                   (random album-length))
      (setq index (1+ index)))
    (when with-cache
      (ivan-emms-last-save ring))

> If you want to prove it without knowing the algorithm, that's a lot
> more difficult.  The basic techniques are in D. Knuth's The Art of
> Computer Programming, Vol. 2: Seminumerical Algorithms.  The state of
> the art has advanced since then, but if you can detect non-randomness
> with your flesh-and-blood ears, Knuth's tests will be enough.

It's noted.
Ivan Kanis

A facility for quotation covers the absence of original thought.
    -- Lord Peter Wimsey

I am listening to "Serge Gainsbourg - Initials B.B.".

reply via email to

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