Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site decwrl.UUCP Path: utzoo!watmath!clyde!cbosgd!ukma!psuvm.bitnet!psuvax1!burdvax!sdcrdcf!ucla-cs!ucbvax!decwrl!dec-rhea!dec-sprite!osman From: osman@sprite.DEC (Eric, DIGITAL, Burlington Ma. 617 273-7484) Newsgroups: net.puzzle Subject: random number wanted between neg inf and pos inf Message-ID: <33@decwrl.UUCP> Date: Mon, 16-Dec-85 16:13:28 EST Article-I.D.: decwrl.33 Posted: Mon Dec 16 16:13:28 1985 Date-Received: Fri, 20-Dec-85 06:03:40 EST Sender: daemon@decwrl.UUCP Organization: Digital Equipment Corporation Lines: 43 >> > Now he tells us that it's got to be uniformly distributed? If such >> >a function exists, the probability of it generating a number between any >> >two arbitrarily large, but finite limits is exactly 0! Why would >> >anyone want a random number generator like that? >> Not zero, since the random number generator will in fact come up with a >> number. The chances are infinitesimal. The difference is admittedly >> very subtle. > >I haven't been able to market this, so here, ABSOLUTELY FREE, is my >generator! It's GUARANTEED to generate ALL positive integers with >equal frequency, if you only run it long enough. > > > int rand() { > return 6; > } >-- >Col. G. L. Sicherman >UU: ...{rocksvax|decvax}!sunybcs!colonel >CS: colonel@buffalo-cs >BI: csdsicher@sunyabva I disagree that this one's output is evenly distributed. There will be a rather high spike at x=6. I'm the original poser of the problem. I'm surprised at the high smart-ass/serious ratio on the responses. The best I've thought of so far for a random number between neg inf and pos inf is: f() = tan (rnd()*pi - pi/2) In words, take a random number between 0 and 1, scale it to an angle between -pi/2 and pi/2. Then take the tangent. Since tangent of such angles ranges from -oo to oo, this produces a random number in desired range. However, I don't think this is evenly distributed. (If not, what is it's distribution ??) Can we scale this function to make it evenly distributed ? /Eric