i am having total no of elements(say 500) in a java class, which will generate a population of 3 diff type (type A,Type B and Type C) of objects with a probability of A=0.3,B=0.2,C=0.5. i am not able to find a nice and easy solution ,can any one help me with a sample code or some reference
Thanks in advance
For each element, generate a random int r between 0 and 9.
If 0 <= r < 3 then Type A.
If 3 <= r < 5 then Type B.
If 5 <= r < 10 then Type C.