cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-215803%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EWie%20kann%20ich%20einen%20zuf%C3%A4lligen%20Startwert%20in%20die%20Funktion%20%E2%80%9ERandom%20Index%E2%80%9C%20setzen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-215803%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20verwende%20Random%20Index%2C%20um%20eine%20Reihe%20von%20Zufallszahlen%20zu%20generieren.%20Ich%20m%C3%B6chte%20jedoch%20jedes%20Mal%2C%20wenn%20ich%20das%20Skript%20ausf%C3%BChre%2C%20denselben%20Satz%20Zufallszahlen%20haben.%20Kann%20ich%20einen%20zuf%C3%A4lligen%20Startwert%20f%C3%BCr%20die%20Zufallsindexfunktion%20festlegen%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216230%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20kann%20ich%20einen%20zuf%C3%A4lligen%20Startwert%20in%20die%20Funktion%20%E2%80%9ERandom%20Index%E2%80%9C%20setzen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216230%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20habe%20mich%20geirrt%2C%20als%20ich%20angegeben%20habe%2C%20dass%20es%20keine%20M%C3%B6glichkeit%20gibt%2C%20den%20Startwert%20f%C3%BCr%20einen%20Random%20Index()%3B%20Die%20Funktion%20Random%20Reset()%20erledigt%20den%20Job%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0ARandom%20Reset(%201%20)%3B%0Ax%3Drandom%20index(100%2C%2010)%3B%0Ashow(x)%3B%0ARandom%20Reset(%201%20)%3B%0Ax%3Drandom%20index(100%2C%2010)%3B%0Ashow(x)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-215812%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20kann%20ich%20einen%20zuf%C3%A4lligen%20Startwert%20in%20die%20Funktion%20%E2%80%9ERandom%20Index%E2%80%9C%20setzen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-215812%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CSTRIKE%3EIch%20glaube%20nicht%2C%20dass%20man%20den%20Startwert%20f%C3%BCr%20den%20Zufallsindex%20festlegen%20kann.Sie%20k%C3%B6nnen%20jedoch%20die%20ben%C3%B6tigte%20Matrix%20einmalig%20generieren%20und%20sie%20dann%20in%20einer%20Textdatei%20speichern.Anschlie%C3%9Fend%20k%C3%B6nnen%20Sie%20die%20Matrix%20aus%20der%20Textdatei%20am%20Anfang%20Ihres%20Skripts%20einlesen%20und%20die%20Matrix%20auf%20diese%20Weise%20festlegen.Hier%20ist%20eine%20einfache%20Darstellung%20der%20Erstellung%20einer%20Matrix%2C%20des%20Speicherns%20in%20einer%20Textdatei%20und%20des%20anschlie%C3%9Fenden%20Abrufens.%3C%2FSTRIKE%3E%3C%2FP%3E%0A%3CPRE%3E%3CSTRIKE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ex%3Drandom%20index(100%2C%2010)%3B%0Ashow(x)%3B%0Asave%20text%20file(%22%24TEMP%2Frandom.txt%22%2C%20char(x))%3B%0Ax%3D%5B%5D%3B%0Ashow(x)%3B%0Ax%3Dparse(load%20text%20file(%22%24TEMP%2Frandom.txt%22))%3B%0Ashow(x)%3B%0A%3C%2FCODE%3E%3C%2FSTRIKE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSTRIKE%3ESie%20k%C3%B6nnen%20auch%20eine%20Datentabelle%20mit%20den%20Matrixwerten%20in%20einer%20Spalte%20erstellen%20und%20die%20Datentabelle%20speichern.%C3%96ffnen%20Sie%20dann%20bei%20Bedarf%20die%20gespeicherte%20Tabelle%20und%20lesen%20Sie%20die%20Werte%20aus%20der%20Spalte%20in%20eine%20Matrix%20ein.%3C%2FSTRIKE%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-215810%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20kann%20ich%20einen%20zuf%C3%A4lligen%20Startwert%20in%20die%20Funktion%20%E2%80%9ERandom%20Index%E2%80%9C%20setzen%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-215810%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHabe%20ein%20Add-In%20gefunden%3A%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMP-Add-Ins%2FRandom-Seed-Reset%2Fta-p%2F21973%22%20target%3D%22_blank%22%3E%20https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMP-Add-Ins%2FRandom-Seed-Reset%2Fta-p%2F21973%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EF%C3%BCr%20einfache%20Werte%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0ARandom%20Reset(%201%20)%3B%0ARandom%20Normal()%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EF%C3%BCr%20ein%20Objekt%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eobj%20%26lt%3B%26lt%3B%20Set%20Seed(%201111%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EF%C3%BCr%20eine%20Plattform%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBoston%20Housing.jmp%22%20)%3B%0Aobj%20%3D%20Partition(%0A%20Y(%20%3Achas%20)%2C%0A%20X(%20%3Acrim%2C%20%3Azn%2C%20%3Aindus%2C%20%3Amvalue%2C%20%3Anox%2C%20%3Arooms%2C%20%3Aage%2C%20%3Adistance%2C%20%3Aradial%20)%2C%0A%20Method(%20%22Bootstrap%20Forest%22%20)%2C%0A%20Set%20Random%20Seed(%201234%20)%2C%0A%20Go%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EProbieren%20Sie%20Random%20Seed%20im%20Drehbuchindex%20aus%2C%20um%20weitere%20Informationen%20zu%20erhalten%3A%3C%2FP%3E%3C%2FLINGO-BODY%3E
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

Recommended Articles