|
-
Nov 10th, 2003, 10:51 AM
#1
Thread Starter
Hyperactive Member
Rnd Function Help
I am trying to use the rnd function to get a random number(ironically enough).
What I would like it to do would be to return smaller numbers more frequently than larger numbers.
For example, the number 1 will be returned a lot more frequently than the number 5.
Would you have any advice??
Thanks,
Matt.
-
Nov 10th, 2003, 11:07 AM
#2
I wonder how many charact
Well, you want a distibution of numbers that is weighted on one side instead of evenly.
Unfortunately, I remember jack from statistics, but in any case, it would probably involve keeping a running tab of how many 'undesireable' numbers fell out of range. And if that running count is too high, discard that random number and try again.
1) get a random number
2) add +1 to your generated number count
3) if its out of your desirable range,
3aaa) add +1 to your undesirable number count
3aab) if the undesirable count is not too high,
use that number,
3bbb) if it is too high, discard that generated number, grab another one.
EDIT: keep a running count of generated/undesirable as a ratio. If the ratio becomes too large, try generating another random number.
-
Nov 10th, 2003, 06:57 PM
#3
Alternatively you can generate the random number between 1 and 10 then subtract 5 and round to the first positive number. Then you would have a 6 to 1 chance of getting the number 1.
-
Nov 10th, 2003, 10:32 PM
#4
Lively Member
Wouldn't that not be random?
It is like wiping your ass with silk, I love it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|