kohler@jacobs.CS.ORST.EDU (kurt kohler) (07/04/90)
We have the need to generate some small (< 100) integers on the PDP-11. It doesn't need to be of terribly high quality, it is just going to be used to generate a constantly changing display on a character cell terminal (VT100, etc.). I don't have access to the Fortran library. We're using RT-11 by the way so if there's something on other OS's it doesn't help. All I really need is some values for A & B in x(n+1) = A * x(n) + B Any ideas would be appreciated! Kurt Kohler Asset Control Systems, Inc. kohler@jocobs.cs.orst.edu Kurt Kohler "I'm a pussycat, not an electrician!" Internet: kohler@jacobs.cs.orst.edu -- Not Dr. McCoy Asset Control Systems, Inc. Corvallis, OR
minow@mountn.dec.com (Martin Minow) (07/05/90)
In article <19191@orstcs.CS.ORST.EDU> kohler@jacobs.CS.ORST.EDU (kurt kohler) writes: > We have the need to generate some small (< 100) integers on the >PDP-11. It doesn't need to be of terribly high quality. /* * The algorithm is based on the mth$random function in the * VMS common run-time library. * * Note that the algorithm is prone to nonrandom sequences when * considering the next pseudorandom number. */ static long seed = 123456789L; long rand() { seed = (69069L * seed + 1); return (seed & 0x7FFFFFFF); } Martin Minow minow@bolt.enet.dec.com
kohler@jacobs.CS.ORST.EDU (kurt kohler) (07/05/90)
In article <1739@mountn.dec.com> minow@bolt.enet.dec.com (Martin Minow) writes: >In article <19191@orstcs.CS.ORST.EDU> kohler@jacobs.CS.ORST.EDU >(kurt kohler) writes: >> We have the need to generate some small (< 100) integers on the >>PDP-11. It doesn't need to be of terribly high quality. > > * The algorithm is based on the mth$random function in the > * VMS common run-time library. > >Martin Minow >minow@bolt.enet.dec.com Thanks for the reply, but I guess I should have been more explicit. What I wanted was a function that could be evaluated with the 16 bit arithmetic on the PDP-11. Actually since all that is required is a 32 bit multiply I could use it I suppose, it would just be more straight forward to have 16 bit constants and a 16 bit result. Kurt Kohler Kurt Kohler "I'm a pussycat, not an electrician!" Internet: kohler@jacobs.cs.orst.edu -- Not Dr. McCoy Asset Control Systems, Inc. Corvallis, OR
mark@mips.COM (Mark G. Johnson) (07/05/90)
In article <19207@orstcs.CS.ORST.EDU> kohler@jacobs.CS.ORST.EDU (kurt kohler) writes: >Thanks for the reply, but I guess I should have been more explicit. What >I wanted was a function that could be evaluated with the 16 bit arithmetic >on the PDP-11. Actually since all that is required is a 32 bit multiply >I could use it I suppose, it would just be more straight forward to >have 16 bit constants and a 16 bit result. Vol. 2 of Cookbook de la Knuth, 2nd edition, section 3.6, suggests some properties that your multiplier, modulus, and addend should have. The following choices have some of his suggested properties; read Knuth and see if you agree. X(0) := 31416 X(n+1) := [ (33573 * X(n)) + 4511 ] mod 65536 note: 2^16 = 65536, so the method above is suited for use on a binary computer with 16-bit wordlength. -- -- Mark Johnson MIPS Computer Systems, 930 E. Arques M/S 2-02, Sunnyvale, CA 94086 (408) 524-8308 mark@mips.com {or ...!decwrl!mips!mark}