Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Number
Message
De
27/11/2001 04:46:29
 
 
À
26/11/2001 14:23:17
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00585489
Message ID:
00586179
Vues:
31
All of the solutions, including mine, show the problem of converting from a "real number" random number to an integer random number.

In the case of using int() to truncate the decimal part, the likelihood of obtaining the upper limit of the random range is very low - ie the probability of rand() returning exactly 1.0.

In the case of using round() to remove the decimal part, the likelihood of obtaining both the upper & lower limit is half that of obtaining any value in between, ie probability of 1 is equivalent of probability of rand()*999 returning less than 0.5, similarly probabilty of obtaining 1000 is probability of rand()*999 return greater than 998.5, whereas values in between have double the range.

To obtain an integer random number generator with all values having equal probability of occuring is more than a trivial one liner, where the range of rand() is 0.0 -> 1.0.
Len Speed
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform