### uniformInt : Why does not this function produce different numbers?

Posted:

**Tue Sep 04, 2018 3:53 pm**Hi everyone

I want to pick 10 number randomly , from a set of i /1*300/.

i use this code :

I want to run this code a few times ,And I want to choose 10 random numbers at first time,

Second time 20, Second time 30, and ... Tue 10 times 100 random numbers.

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:
What should I do to avoid duplicate numbers every time?

Why does not this function produce different numbers?

Best,

linkho

I want to pick 10 number randomly , from a set of i /1*300/.

i use this code :

Code: Select all

```
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;
```

Second time 20, Second time 30, and ... Tue 10 times 100 random numbers.

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:

Code: Select all

```
* 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
```

Code: Select all

```
* 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
```

Why does not this function produce different numbers?

Best,

linkho