[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Bug in random() in builtin.c
From: |
Bob Jewett |
Subject: |
[bug-gawk] Bug in random() in builtin.c |
Date: |
Wed, 28 Aug 2013 17:52:46 -0700 |
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
builtin_diffs.txt
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-gawk] Bug in random() in builtin.c,
Bob Jewett <=