Fix to random.m
Thomas Charles CONWAY
conway at cs.mu.OZ.AU
Wed Oct 28 15:15:16 AEDT 1998
Hi
Here's a simple fix for the poor behaviour of random.m reported in
the mercury-users mailing list.
--
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor. )O+
library/random.m:
Change the coefficients for the linear-congruential generator.
They now assume only 31 bits (unsigned) rather than 32. This
should prevent the defective behaviour reported on the
mercury-users mailing list.
cvs diff: Diffing .
Index: random.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/random.m,v
retrieving revision 1.15
diff -u -r1.15 random.m
--- random.m 1998/01/23 12:33:30 1.15
+++ random.m 1998/10/28 04:11:58
@@ -12,6 +12,8 @@
% uses a threaded random-number supply. It could be made non-unique, but
% since each thread returns the same list of random numbers, in the interests
% of safety, it is declared with (backtrackable) unique modes.
+% The coefficients used in the implementation were taken from Numerical
+% Recipes in C (Press et al), and are originally due to Knuth.
%
%---------------------------------------------------------------------------%
@@ -64,7 +66,7 @@
:- pred random__params(int, int, int). % a, c, m
:- mode random__params(out, out, out) is det.
-random__params(2416, 374441, 1771875).
+random__params(9301, 49297, 233280).
random__init(I0, RS) :-
copy(I0, RS).
More information about the developers
mailing list