Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting a Winner
Message
De
14/06/1999 19:53:28
 
 
À
14/06/1999 08:50:38
George Simon
GS Data Technologies, LLC
Cincinnati, Ohio, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00226460
Message ID:
00229790
Vues:
21
You are right and wrong in the same time. :) I cannot give a predictable algorithm.

Here's why I say it is not correctly random:
The SELECT may extract more than one record with the same random key. If you take the first record (or according with any other rule) from the resulted cursor, than this second choice is not random. Let's say that SELECT returns records in the phisycal order when no other rule is in effect. This would mean that the records at the beginning of the table have more chances to be selected as the final winner. This says that the chance is not the same for all records, thus, my statement.

If you don't believe me, you can make tests with rand()*2 (it doesn't reduce the random character of the alghorithm). I bet it will balance to the records in the first half of the table.

I would say that if the number of records is much less than 1000000, the random choice is almost correct and it doesn't matter.

Vlad

>I disagree. Random does not necessarily mean unique. If you want to make sure you do not select the same person, then store the previous winners in a table for comparison. However, unless you can show me a predictable algorithm used by SELECT TOP 1 RAND()*1000000 etc. then it is random.
>
>George
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform