- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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:
- GLaDOS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);