Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

selecting a number with certain probability

807598Sep 23 2006 — edited Sep 24 2006
Hi guys,
i've used the random number method is java and know that it outputs a random number with equal probability.
OK here's my question. i've got a set of numbers from 1 to N and I want to output ONE number in the set say r with probability r/N , how do I do that??

ex: the set is {1,100} and i want to pick 19 with a probability 19/100

Thanks in advance for any help provided!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2006
Added on Sep 23 2006
30 comments
332 views