[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Bug in random() in builtin.c
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] Bug in random() in builtin.c |
Date: |
Wed, 25 Sep 2013 12:50:52 +0300 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi. Re this:
> Date: Wed, 28 Aug 2013 17:52:46 -0700
> From: Bob Jewett <address@hidden>
> To: address@hidden, address@hidden, address@hidden
> Subject: [bug-gawk] Bug in random() in builtin.c
>
> Dear address@hidden,
>
> The present rand() function in gawk has a bug in the correlation
> of consecutive values. This causes some uses of rand() to
> produce non-white noise. There may be other problems as well.
> You can repeat the problem by:
>
> gawk 'BEGIN{for(i=0;i<2^14;i++)print ((rand()-0.5)*(rand()-0.5))^2;}' |
> fft |
> low-pass-filter |
> plot
>
> The particular place we saw the problem was with Knuth's
> suggested method of generating gaussian-distributed random values
> because it uses two consecutive random values and combines them
> in a way similar to the above.
>
> It would probably be better to fix random(), which also has a pair-wise
> correlation problem, but that's beyond my level of expertise.
>
> Best regards,
> Bob Jewett`
> address@hidden
> +1-408-553-7449
Thanks. I have applied your patch in the master branch. Since this produces
a change in behavior I'm going to wait until the next major release to
foist it upon the users. Anyone who really cares will be able to cherry-pick
the patch into the stable code base via git.
I will also be adding the test program you sent me to the test suite.
Much thanks,
Arnold
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [bug-gawk] Bug in random() in builtin.c,
Aharon Robbins <=