Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 1996 16:46:22 +0300 (MSK)
From:      =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?= (aka Andrey A. Chernov, Black Mage) <ache@astral.msk.su>
To:        imb@scgt.oz.au (michael butler)
Cc:        current@freebsd.org
Subject:   Re: random .. not so ..
Message-ID:  <199603291346.QAA00701@astral.msk.su>
In-Reply-To: <199603290938.UAA12872@asstdc.scgt.oz.au> from "michael butler" at "Mar 29, 96 08:38:17 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> >    BSD:    state[i] = 1103515245 * state[i - 1] + 12345;
> >    Linux:  state[i] = 1103515145 * state[i - 1] + 12345;
> >			      ^
> That line is utterly WRONG in BOTH implementations.  The state it creates
> is so incredibly UNRANDOM, that seeding is almost pointless.  The following
> program outputs a PBM image showing a bit in the result of successive calls
> to random(), for consecutive values of srandom().  
> 
> The results are TERRIBLE (for example, the 151st value returned by random()
> is 0 for seed 0..14, then 1 for seed 15..30, then 0 for seed 31..46, etc.)

Yes, the bug really hits, here is some of FreeBSD-current results,
very visible patterns exists. They created by proposed program:
a | split -l 100; paste x[a-b]* | tr -d "\t"

I plan to aply proposed fix, if nobody against.

1100110011001100110011001100110011001100110011001100
1010101010101010101010101010101010101010101010101010
0110011001100110011001100110011001100110011001100110
1010101010101010101010101010101010101010101010101010
0101010101010101010101010101010101010101010101010101
1100110011001100110011001100110011001100110011001100
1010101010101010101010101010101010101010101010101010
0101010101010101010101010101010101010101010101010101
0110011001100110011001100110011001100110011001100110
0011001100110011001100110011001100110011001100110011
1100110011001100110011001100110011001100110011001100
0110011001100110011001100110011001100110011001100110
1100110011001100110011001100110011001100110011001100
1010101010101010101010101010101010101010101010101010
1100110011001100110011001100110011001100110011001100
0101010101010101010101010101010101010101010101010101
1100110011001100110011001100110011001100110011001100
1001100110011001100110011001100110011001100110011001
0011001100110011001100110011001100110011001100110011
0011001100110011001100110011001100110011001100110011
1001100110011001100110011001100110011001100110011001
1111111111111111111111111111111111111111111111111111
1010101010101010101010101010101010101010101010101010
0000000000000000000000000000000000000000000000000000
0101010101010101010101010101010101010101010101010101
1111111111111111111111111111111111111111111111111111
1100110011001100110011001100110011001100110011001100
0110011001100110011001100110011001100110011001100110

-- 
Andrey A. Chernov        : And I rest so composedly,  /Now, in my bed,
ache@astral.msk.su       : That any beholder  /Might fancy me dead -
http://dt.demos.su/~ache : Might start at beholding me,  /Thinking me dead.
RELCOM Team,FreeBSD Team :         E.A.Poe         From "For Annie" 1849



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603291346.QAA00701>