Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random numbers - the most efficient way
Message
From
09/09/2004 08:57:28
 
 
To
09/09/2004 01:26:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00939849
Message ID:
00940573
Views:
20

But, suppose you have a cursor with a million random integer values, not related to each other. If you want 40 random values, taking 40 sequential records is just as good as taking 40 at random.


This is like to use a repeat of RAND(seed) with a RAND() start.
 x=INT(RAND()*1000000)
FOR k=1 TO 40
  ? x
   x=INT(RAND(x)*1000000)
NEXT
But, this is correct for a single shot. ( the values within a shot are not correlated )
But this generates one correlation between more shots
( if you get the same start point, se sequence is the same ).

The next is a pure random process,
no correlation within a shot and no correlation between more shots:
FOR k=1 TO 40
   x=INT(RAND()*1000000)
  ? x
NEXT
Fabio
Previous
Reply
Map
View

Click here to load this message in the networking platform