Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Number
Message
From
27/11/2001 04:46:29
 
 
To
26/11/2001 14:23:17
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00585489
Message ID:
00586179
Views:
30
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
Previous
Reply
Map
View

Click here to load this message in the networking platform