Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random numbers - the most efficient way
Message
De
08/09/2004 02:28:33
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00939849
Message ID:
00940194
Vues:
22
This may be beating the topic to death - but here's another idea, anyways:

If your data are truly random, then to get 40 random values, all you need to do is pick a random start point, then select the next 40 records! Those 40 records will be as random as any 40 you could pick "randomly". (You'd have to handle the case where your start point was near the end of the file by wrapping back around to the beginning).

Suppose, for example, you're a telco and you're tracking the starting datetime of cell phone calls placed in Manhattan. If you want to hand out prizes to 40 random subscribers, picking a start datetime and selecting the next 40 records will likely be just as random as picking 40 random datetimes. In both cases you'd have to prevent duplicates, of course.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform