问题
I want to test my model , I need to test it in some data , I want to generate data , in fact I want to have 125 different parameter from 0 to 10000.
For example , in below we have 4 different parameter ,from 1 to 300.
Set I/0*300/;
Parameter MyParameter;
MyParameter /4 1,10 1,42 1,87 1/;
I don't want to do this by hand.
Is there any method that I generate it automaticly.
another way asking:
how can Select 4 random element of a set ' I' , without repetition?
回答1:
Try this:
Set I /0*300/
picks /p1*p4/;
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;
来源:https://stackoverflow.com/questions/52028444/generate-100-data-randomly-or-select-if-it-is-possible