cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Shunee
Level I

How can I set random seed into Random Index function?

I use Random Index to generate a marix of random numbers. However, I would like to have same set of random numbers everytime I run the script. Can I set random seed for Random Index function?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How can I set random seed into Random Index function?

I was incorrect when I stated that there isn't a way to set the seed for a Random Index();  The Random Reset() function will do the job

Names Default To Here( 1 );

Random Reset( 1 );
x=random index(100, 10);
show(x);
Random Reset( 1 );
x=random index(100, 10);
show(x);
Jim

View solution in original post

3 REPLIES 3
Mauro_Gerber
Level IV

Re: How can I set random seed into Random Index function?

Found an addin:  https://community.jmp.com/t5/JMP-Add-Ins/Random-Seed-Reset/ta-p/21973

 

For simple values:

Names Default To Here( 1 );
Random Reset( 1 );
Random Normal();

For an object:

obj << Set Seed( 1111 );

For a platform:

dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
obj = Partition(
	Y( :chas ),
	X( :crim, :zn, :indus, :mvalue, :nox, :rooms, :age, :distance, :radial ),
	Method( "Bootstrap Forest" ),
	Set Random Seed( 1234 ),
	Go
);

 

Try Random Seed in the scritping index for further info:

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
- GLaDOS
txnelson
Super User

Re: How can I set random seed into Random Index function?

I do not believe that you can set the seed for Random Index.  However, you can do a one time generation of the matrix you need and then save it to a text file.  You can then read in the matrix from the text file at the beginning of your script, and set the matrix that way.  Here is a simple illustration of creating a matrix, saving it to a text file, and then how to retrieve it.

x=random index(100, 10);
show(x);
save text file("$TEMP/random.txt", char(x));
x=[];
show(x);
x=parse(load text file("$TEMP/random.txt"));
show(x);

You could also create a data table with the matrix values in a column, save the data table.  Then as needed open the saved table and read the values from the column into a matrix.

Jim
txnelson
Super User

Re: How can I set random seed into Random Index function?

I was incorrect when I stated that there isn't a way to set the seed for a Random Index();  The Random Reset() function will do the job

Names Default To Here( 1 );

Random Reset( 1 );
x=random index(100, 10);
show(x);
Random Reset( 1 );
x=random index(100, 10);
show(x);
Jim