| Author | Topic: re : Random() |
---|
| Chris Palmer | re : Random()
on Thu, 11 Aug 2005 12:25:53 +0100 |
| Thomas Braun | Re: re : Random()
on Thu, 11 Aug 2005 12:03:44 +0200Chris Palmer wrote:
> If I run this procedure . . .
>
> clear
> ! time 12:00 /// resetting the system clock to 12:00
Why exactly are you doing this?
Thomas |
| Chris Palmer | Re: re : Random()
on Thu, 11 Aug 2005 13:41:35 +0100I'm only resetting the clock to test the RANDOM() function, I need to be
sure that my numbers are 100% random and are not just a 1/1000 chance
Thanks
"Thomas Braun" <nospam@software-braun.de> wrote in message
news:zqek72t8amt5.175pio7wsuhx0$.dlg@40tude.net...
> Chris Palmer wrote:
>
> > If I run this procedure . . .
> >
> > clear
> > ! time 12:00 /// resetting the system clock to 12:00
>
> Why exactly are you doing this?
>
> Thomas |
| Thomas Braun | Re: re : Random()
on Thu, 11 Aug 2005 16:00:40 +0200Chris Palmer wrote:
> I'm only resetting the clock to test the RANDOM() function, I need to be
> sure that my numbers are 100% random and are not just a 1/1000 chance
You will never get real random numbers without using a randomness source
(e.g. a physical process) which is known to be unpredictable (such as
radioactive decay).
Just a short quote from this (
http://en.wikipedia.org/wiki/Random_Number_Generator ) article:
"Anyone who uses software to produce random numbers is in a state of sin"
But maybe you are looking for a PRNG (pseudo random number generator) :
http://en.wikipedia.org/wiki/Pseudorandom_number_generator
I'm not sure which of the proposed algorithms is used by the random()
function.
Thomas |
| Regan Cawkwell | Re: re : Random()
on Thu, 11 Aug 2005 12:59:42 +0100Chris Palmer wrote:
> Hello
>
> If I run this procedure . . .
>
> clear
> ! time 12:00 /// resetting the system clock to 12:00
>
> for aaa = 1 to 20
> bbb = random()
> ? bbb
> next
>
> . . . . I get the same 20 random numbers everytime, is there any other
> method of getting a random number without using the clock (a long shot I
> know).
>
> If not, could somebody please explain what part of the clock is used -
> i.e. 100'th of a second, 1000's etc
>
> Any Info would be usefull
>
> Thanks
> Chris
Not sure but could old Clipper code help? If so, try:
http://www.the-oasis.net/ftpmaster.php3?content=ftpgenrl.htm
look for random.zip.
Regan Cawkwell
Company : Real Business Applications Ltd
Title : Technical Support
Websites : www.rbauk.com www.rba-uk.com www.retailerexpress.co.uk
Email : regan@rba-uk.com
------------------------------------------------------ |
| Pablo Botella | Re: Random()
on Thu, 11 Aug 2005 15:19:36 +0200Hi,
Sometime ago I was using this function to generate some random series not a
true random generator, but was fit my needs.
//---------------------------------------------------------------
function PseudoRandom(nMax)
return ( _nTicks_() % nMax) + 1
//---------------------------------------------------------------
static function _nTicks_()
local i := Replicate(Chr(0),8)
local nDll:=DllLoad("Kernel32.dll")
DllCall(nDll,32,"QueryPerformanceCounter", @i)
DllUnLoad(nDll)
return ( Bin2U(i)+(2**32)*(Bin2U(Right(i,4))) )
//---------------------------------------------------------------
Hope this can help you. Regards,
Pablo |
| Chris | Re: Random()
on Thu, 11 Aug 2005 17:57:30 +0200 |
| Greg Doran | Re: re : Random()
on Thu, 11 Aug 2005 20:44:52 +0100Hi Chris,
For a start, the random sample rate is generally faster than the clock
can produce samples unless there is loading on the processor.
I have attached a (1 - 100,000) linear congruential Pseudo-Random
Number Generator I coded some time back using modified Seconds() as the
base seed.
Give it a try.
Greg Doran, Dublin Ireland. gdRand.png gdRand.prg |
| Richard Dalzell | Re: re : Random()
on Thu, 11 Aug 2005 20:19:20 -0500Greg,
Could you re-post your gdRand.Prg file, I was able to open/save this file.
I was able to open/save the gdRand.Png file just fine.
Thanks,
Rick |
| Richard Dalzell | Re: re : Random()
on Thu, 11 Aug 2005 20:34:34 -0500Sorry, my security settings had been changed blocking the download. |