Path: cactus.org!cs.utexas.edu!howland.reston.ans.net!agate!library.ucla.edu! + csulb.edu!paris.ics.uci.edu!news.claremont.edu!jarthur.cs.hmc.edu! + ebrandt From: ebrandt@jarthur.cs.hmc.edu (Eli Brandt) Newsgroups: sci.crypt Subject: Re: modran(x) Date: 25 Feb 1994 02:17:56 GMT Organization: Harvey Mudd College, Claremont CA Lines: 15 Message-ID: <2kjn4k$cc9@jaws.cs.hmc.edu> References: <17.11880.864.0N63EC25@almac.co.uk> <2kj4is$akq@transfer.stratus. + com> NNTP-Posting-Host: jarthur.cs.hmc.edu In article <2kj4is$akq@transfer.stratus.com>, Carl Ellisonwrote: >For example, if ranno() were to return a number in the range 0..14 and x >were 10, then (ranno() % x) would produce an element in [0..4] twice as >often as an element in [5..9]. So, the distribution is not uniform. Related problem: you often see code like if (!(rand()%1000)) { ... } , with the intent that the block be run with probability .001, which it won't be. It's pretty close on a 32-bit machine, but not correct. Eli ebrandt@jarthur.claremont.edu PGP 2 key by finger or e-mail "Your hideous criminal clock, your insidious time bomb, is tick-tick-ticking." -- L. Detweiler