Random Generator Question
Hi guys,
I'm wanting to know how would I go about creating some form of random where I have range of 3 number (say in an simple array). And I want to say the likely hood of picking the number at index 0 is 25%, index 1 is 50%, index 2 is 75%.
With the Java random generator class it seems that picking the numbers wtih the range is done by an equal fairness. So, how do i customise the randomness so the likely is more weighted to choose certain numbers in the range over others.
Many thanks.
Message was edited by:
_Visionary_
Maybe its the easy way, make a switch case, and make a random int of 4, and something like this:
case 1:
"string 50%"
case 2:
"same string 50%!
case 3:
"a string of 25%"
case 4:
"the other 25% string"
is logic and maybe a stupid solution, but effective.
> ...
> And I want to say the likely hood of picking the number at index
> 0 is 25%, index 1 is 50%, index 2 is 75%.
A total of 125%?
Anyway, here's a hint:
0 = 25%
1 = 30%
2 = 40%
3 = 5%
Get a random number N between 1 and 100. If N is between
- 1 and 25, return 0
- 25 and 55, return 1
- 55 and 95, return 2
- 95 and 100, return 3