Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: random implementation

From: chris:starforge:demon at: 8-Feb-2001 10:51

Allen Kamp wrote:
> > to put it another way, someone hasn't just looked at the incredibly dire > > ANSI C rand() implementation and copied it have they? (Please say no...) > > > > I believe it's based on the function you suggest. Sorry. > > But there is also random/secure. (Depends on the version of rebol you are > using).
I haven't run any tests on that yet but what are the differences between normal and /secure? And how is the range restriction implemented? For example, doing something like outvalue = 1 + (calculatedRandom % maxValue) is less random than outvalue = 1 + ((calculatedValue * maxValue) / (maximumRandom + 1)) as LCGs have less random lower order bits. I want to use the random command as part of a Beauford PSC so the sequential correlation on successive calls need to be as low as possible. The standard ANSI example implementation is fairly poor (although not disasterously so) for this and unless the increment, multiplier and modulus are chosen very carefully the generator is almost useless. I may try to implement a subtracitve method number generator (see Knuth D.E 1981, Seminumerical Algorithms 2nd Ed, vol 2 of the Art of Computer Programming) as that should not suffer from the correlation problem.... Chris -- New sig in the works Explorer2260 Designer and Coder