Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting a Winner
Message
From
14/06/1999 19:53:28
 
 
To
14/06/1999 08:50:38
George Simon
GS Data Technologies, LLC
Cincinnati, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00226460
Message ID:
00229790
Views:
22
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform