Date: Sat, 18 Nov 1995 13:44:41 -0500 (EST) From: Marc Ramirez <mrami@mramirez.sy.yale.edu> To: Frank Volf <volf@oasis.IAEhv.nl> Cc: freebsd-questions@freebsd.org Subject: Re: What's wrong with this code??? Message-ID: <Pine.BSF.3.91.951118123037.23019A-100000@mramirez.sy.yale.edu> In-Reply-To: <199511191351.OAA04737@oasis.IAEhv.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 19 Nov 1995, Frank Volf wrote: > To my surprise the range of numbers generated is not random at all between > multiple invocations of the program. In fact the random generator seems > to start again after 16 invocations (with 1 second delay between them > so t has incremented): Well, I don't have the source code handy, but apparently... Given R(s)= {initstate(s); return random();}, R(s) = R(s+2^(n+1)) (mod 2^n) R(s) = (0x23fe0e9a)s + 0x1a679542 (mod 2^n) This is just from playing around; I don't know about moduli that aren't powers of 2. My advice therefore would be to take higher bits since they will have a greater period (e.g., (random()/65536)%8).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.951118123037.23019A-100000>