[alexandria-devel] Bug in gaussian-random

Tamas Papp tkpapp at gmail.com
Tue Oct 2 07:29:00 UTC 2012


On Mon, Oct 01 2012, Andy Peterson <andy.arvid at gmail.com> wrote:

> function: gaussian-random (&optional min max)
>
> If gaussian-random is called with a value for min and nil for max (or vice
> versa), the function could enter an infinite loop.
>
> example (gaussian-random 100 nil)  almost always causes an infinite loop.
>
> If the first call to the local function "gauss" creates a value that does
> not satisify min,
> then the local function "guard" enters an infinite loop because guard is
> called with a value for max that is less than min.

Hi Andy,

The algorithm used by alexandria is not suitable for this kind of
thing.  Think about it: you are talking about a 100 sigma event.  Even
for 10 sigmas, the probability is around 1e-25; for 100 sigmas it is
below 1e-2000.  Technically, you are not seeing an infinite loop, only a
very long calculation using an unsuitable algorithm.

You need to use other algorithms, eg an accept-reject using a scaled
exponential.  My library cl-random has some code for this in the
experimental branch, it has been unit-tested for up to ~7 sigmas (not
more because the sampling properties of the distribution are tricky to
calculate above that and I haven't had the need to implement it).
Please let me know if you need it, I will clean it up and push to the
repo (which is bound to happen in a few weeks anyway).

Best,

Tamas




More information about the alexandria-devel mailing list