Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!stjhmc!p12.f56.n114.z1.fidonet.org!Chris.Gehlker From: Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) Newsgroups: comp.sys.mac.programmer Subject: RE: Is Random() random? Message-ID: <31359.275BAB9A@stjhmc.fidonet.org> Date: 4 Dec 90 13:55:47 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.26) Organization: FidoNet node 1:114/56.12 - AZ MAC UG, Phoenix AZ Lines: 20 > how random is the Toolbox routine Random()? IM-I says it returns > an integer in the range -32767 (not -32768) to 32,767 before > cycling. does this mean it will hit every number in that range > once before repeating? and why the seemingly strange range It definately won't hit every number once before repeating. The strange range makes it easy to scale because you can use Random() * MaxInt / ScaleFactor or abs(Random) * MaxInt / Scalefactor. Other formulations to get unifrom extendeds, longs or shorts over any give range will suggest themselves. They all rely on the distribution of Random() being symetric about 0. If Random() returned values from -32768 to 32767 it would be a real bitch to scale it and still have a uniform distribution. Yeah that was real rambling but it's late. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org