Which JMP function can generate a non-repeating integer between two values?I tried “Random Integer()”, but it produces duplicate integers. Thanks!
Data Blending and CleanupRe: Which JMP function can generate a non-repeating integer between two values?And another way:
Names Default to Here( 1 );
random order = Function( { min, max },
min = Floor( min ); max = Floor( max );
Index( min, max )[Rank( J( max-min+1, 1, Random Uniform() ) )];
);
Show( random order( 5, 10 ) );Re: Which JMP function can generate a non-repeating integer between two values?@lwx228 ,
This is just an alternate method relying on the JMP function Random Shuffle
Names Default to Here(1);
ibeg = 257;
iend = 500;
random_all = As List( Random Shuffle( Transpose(ibeg::iend) ) );
//suppose you only want 100
vals = random_all[1::100];
show(random_all, nitems(random_all), iend-ibeg+1 );
show(vals, nitems(vals));
I felt like a slacker, given Jim's elegant function. [grin] The attached script includes a function that uses this range/shuffle/subset method. Jim, @txnelson, your function name was spot on, so I used it.
'Imitation is the sincerest form of flattery that mediocrity can pay to greatness.' - Oscar Wilde
Re: Which JMP function can generate a non-repeating integer between two values?I do not believe there is such a function in JMP, but it is very simple to create one
Names Default To Here( 1 );
uniqueRandomInteger = Function( {n, min, max},
{defaultlocal},
hold = [];
For( i = 1, i <= n, i++,
val = Random Integer( min, max );
While( N Rows( Loc( hold, val ) ) > 0,
val = Random Integer( min, max )
);
hold = hold |/ Matrix( val );
);
hold;
);
x=uniqueRandomInteger(10,100,200)