Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random numbers - the most efficient way
Message
De
09/09/2004 08:57:28
 
 
À
09/09/2004 01:26:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00939849
Message ID:
00940573
Vues:
21

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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform