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

random implementation

 [1/11] from: al::bri::xtra::co::nz at: 8-Feb-2001 15:38


> How is the random command implemented? If it is based on a linear
congruential algorithm, what are the multiplier, increment and modulus? Or 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. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [2/11] from: allenk:powerup:au at: 8-Feb-2001 19:56


----- Original Message ----- From: "Andrew Martin" <[Al--Bri--xtra--co--nz]> To: <[rebol-list--rebol--com]> Sent: Thursday, February 08, 2001 12:38 PM Subject: [REBOL] Re: random implementation
> > How is the random command implemented? If it is based on a linear > congruential algorithm, what are the multiplier, increment and modulus? Or > 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). ? random USAGE: RANDOM value /seed /secure DESCRIPTION: Returns a random value of the same datatype. RANDOM is an action value. ARGUMENTS: value -- Maximum value of result (Type: any) REFINEMENTS: /seed -- Restart or randomize /secure -- Returns a cryptographically secure random number. Cheers, Allen K

 [3/11] 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 http://www.starforge.co.uk

 [4/11] from: robbo1mark:aol at: 8-Feb-2001 6:11


Regards Random implementation algorithms is it surely not possible we could generate a better "RANDOM" number sequence using a different algorithm in REBOL as a mezzainine function at least till RT decide to *fix* things. If anybody on this list has a good knowledge of RANDOM algorithms, please send them to me and I'll knock something up as I've had problems with this recently too. Iam also looking for a better way to generate RANDOM for inclusion in OSCAR: :REBOL the coming open source REBOL. cheers, Mark Dickson

 [5/11] from: chris:starforge:demon at: 8-Feb-2001 11:36


[Robbo1Mark--aol--com] wrote:
> "RANDOM" number sequence using a different algorithm > in REBOL as a mezzainine function at least till RT > decide to *fix* things.
RT aren't really to blame: random number generation is an arcane art that a lot of books and courses tend to cover badly. Very few people realise that the algorithm suggested by ANSI is flawed simply because it's the standard - it must be safe. They implemnt it or a variation of it because it's easily available, widely used and seldom criticised outside scientific software circles.
> If anybody on this list has a good knowledge of RANDOM > algorithms, please send them to me and I'll knock > something up as I've had problems with this recently too.
I wouldn't say I'm an expert, but I have quite a lot of experience in writing them. If you want a good introduction, Numerical Recipies in C has a good chapter on random number generation. I will probably implement a subtractive method generator tonight and post the code to the list anyway... Chris -- New sig in the works Explorer2260 Designer and Coder http://www.starforge.co.uk

 [6/11] from: gjones05:mail:orion at: 8-Feb-2001 5:56


I know "zip" about random number generators, but I just happened to run across this site (was it a "random" coincidence??? :-). It may or may not be of help. http://random.mat.sbg.ac.at/generators/ --Cheers

 [7/11] from: robbo1mark:aol at: 8-Feb-2001 8:16


I never meant to imply that REBOL Technologies Inc. are in anyway to "Blame" for this situation rather than as proprietary closed source developers *they* are the only ones who can "FIX" the REBOL implementation of RANDOM. Assuming "FIX" is the correct term. If this were OSCAR and open source REBOL you would be empowered to improve this feature yourself. That is all I was trying to say. cheers, Mark Dickson

 [8/11] from: holger:rebol at: 8-Feb-2001 7:44


On Thu, Feb 08, 2001 at 10:51:15AM +0000, Chris wrote:
> Allen Kamp wrote: > > 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
The default algorithm is fast, but probably not suitable for your purposes.
> outvalue = 1 + (calculatedRandom % maxValue) > > is less random than > > outvalue = 1 + ((calculatedValue * maxValue) / (maximumRandom + 1))
random/secure uses SHA1 as the iterator function. It is not an LCG, and provides cryptographically strong non-linearity between all bits and bit combinations, so it should not suffer from the problem you described above. -- Holger Kruse [holger--rebol--com]

 [9/11] from: chris:starforge at: 7-Feb-2001 19:44


Hi, How is the random command implemented? If it is based on a linear congruential algorithm, what are the multiplier, increment and modulus? Or 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...) Chris -- New sig in the works Explorer 2260, Designer and Coder http://www.starforge.co.uk -- Cleveland? Yes, I spent a week there one day.

 [10/11] from: gbash:computerra:ru at: 9-Feb-2001 9:10


Hello GS, Thursday, February 08, 2001, 2:56:49 PM, you wrote: GJ> I know "zip" about random number generators, but I just happened to run GJ> across this site (was it a "random" coincidence??? :-). It may or may not GJ> be of help. GJ> http://random.mat.sbg.ac.at/generators/ By the way, you could use a truly random nondeterministic number generator from Intel, called Intel RNG and implemented in all of its modern chipsets: i810, 1815, 820, 840, and so on... More information is available at http://sourceforge.net/projects/gkernel/ and in Intel 82802 Firmware Hub: Random Number Generator Programmer's Reference Manual December 1999 Order Number: 298029-001 R But I don't know if it's possible to access it from Rebol ;-) GJ> --Cheers
>> Robbo1Mark wrote: >>
<<quoted lines omitted: 23>>
>> >> Chris
-- Best regards, George mailto:[gbash--computerra--ru]

 [11/11] from: chris:starforge:demon at: 9-Feb-2001 10:14


George Bashilov wrote:
> By the way, you could use a truly random nondeterministic > number generator from Intel,
<<quoted lines omitted: 6>>
> December 1999 Order Number: 298029-001 R > But I don't know if it's possible to access it from Rebol ;-)
I'd be surprised ;) The other problem is that it would restrict any script that used it to intel chipset systems - not exactly in fitting with the Rebol ethos. Chris -- New sig in the works Explorer2260 Designer and Coder http://www.starforge.co.uk

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted