On Tue, Feb 04, 2003 at 15:23:28 +0100, Dag-Erling Smorgrav wrote:
> "Andrey A. Chernov" <[EMAIL PROTECTED]> writes:
> > On Tue, Feb 04, 2003 at 14:43:57 +0100, Dag-Erling Smorgrav wrote:
> > > All that being said, adding 1 to *ctx before returning it (see patch)
> > > adresses both of your objections: a seed of 0 will not cause the LCG
> > > to get stuck, and the result of rand() will range between 0 and
> > > RAND_MAX inclusive.
> > Adding +1 you break algorithm formulae badly from math point of view,
> > something else then given formulae not allowed here. You can change 'a' 
> > parameter to anything you want, but not add something at the end.
> 
> Do the math - adding 1 after the modulo operation is equivalent to
> setting a == k.

Repeated k may affect distribution. Better variant will be with a != k.

-- 
Andrey A. Chernov
http://ache.pp.ru/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to