06.06.2009, 14:49
Hey,
I've got an analogy. Imagine you have 4 numbers (0, 1, 2, and 3) and you put them into a hat (so you now have 4 numbers in the hat), if you stick your hand in and pick one of these numbers the probability of getting any one of them is 1/4, and this is the equivalent of Random(3) in pawn.
Now let's say you have the same 4 numbers but you have 1 number 0, 2 number 1s, 3 number 2s, and 4 number 3s. So if you put them into a hat now you have 10 numbers from 0-3. If you stick your hand in and pick one, the probabilities are:
- 1/10 for the number 0
- 2/10 for the number 1
- 3/10 for the number 2
- 4/10 for the number 3
What I want to know is what is the equivalent to this in code? I've spent days trying to figure it out and I just can't find a bias free way to do it. I need it because basically I want the numbers, in this case, to be random events in my script where some events are more likely to happen than others...help will be greatly appreciated. Thanks!
I've got an analogy. Imagine you have 4 numbers (0, 1, 2, and 3) and you put them into a hat (so you now have 4 numbers in the hat), if you stick your hand in and pick one of these numbers the probability of getting any one of them is 1/4, and this is the equivalent of Random(3) in pawn.
Now let's say you have the same 4 numbers but you have 1 number 0, 2 number 1s, 3 number 2s, and 4 number 3s. So if you put them into a hat now you have 10 numbers from 0-3. If you stick your hand in and pick one, the probabilities are:
- 1/10 for the number 0
- 2/10 for the number 1
- 3/10 for the number 2
- 4/10 for the number 3
What I want to know is what is the equivalent to this in code? I've spent days trying to figure it out and I just can't find a bias free way to do it. I need it because basically I want the numbers, in this case, to be random events in my script where some events are more likely to happen than others...help will be greatly appreciated. Thanks!