I asked this question Generate 100 data randomly, or select if it is possible a few days ago. Now when I want to pick 10 number randomly , from a set of i /1*300/. i use this code :
Set I /0*300/
picks /p1*p10/;
Scalar pick;
Parameter MyParameter(I);
MyParameter(I) = 0;
loop(picks,
pick = uniformInt(1, card(I));
* Make sure to not pick the same one twice
while(sum(I$(pick=ord(I)),MyParameter(I))=1,
pick = uniformInt(1, card(I))
Display 'here';
);
MyParameter(I)$(pick=ord(I))=1;
);
Display MyParameter;
I want to run this code a few times ,And I want to choose 10 random numbers at first times. 20 selection in Second times, 30selection in third times , ... ,100 selection in 10th .
In addition, I need to select new numbers every time, i mean , the numbers that are selected the second time must be different from numbers that are selected the first time.
but uniformInt Every time,selects repetitive numbers. For example, the results for the selection of 10 and 20 are as follows:
* for picks /p1*p10/;
21 1.000, 52 1.000, 68 1.000, 88 1.000, 91
1.000, 106 1.000
151 1.000, 166 1.000, 254 1.000, 258 1.000
And result for 20 selected is:
* for picks /p1*p20/;
21 1.000, 40 1.000, 49 1.000, 52 1.000, 68
1.000, 76 1.000
88 1.000, 91 1.000, 106 1.000, 132 1.000, 151
1.000, 166 1.000
175 1.000, 193 1.000, 202 1.000, 230 1.000, 254
1.000, 258 1.000
299 1.000
21,52,68,88,91,106,151,166,254,258 are duplicate in second time.
What should I do to avoid duplicate numbers every time? Why does not this function produce different numbers?