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%3EComment%20puis-je%20d%C3%A9finir%20une%20graine%20al%C3%A9atoire%20dans%20la%20fonction%20Random%20Index%26nbsp%3B%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-215803%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'utilise%20Random%20Index%20pour%20g%C3%A9n%C3%A9rer%20un%20marix%20de%20nombres%20al%C3%A9atoires.%20Cependant%2C%20j'aimerais%20avoir%20le%20m%C3%AAme%20ensemble%20de%20nombres%20al%C3%A9atoires%20%C3%A0%20chaque%20fois%20que%20j'ex%C3%A9cute%20le%20script.%20Puis-je%20d%C3%A9finir%20une%20valeur%20al%C3%A9atoire%20pour%20la%20fonction%20Random%20Index%26nbsp%3B%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%3ERe%20%3A%20Comment%20puis-je%20d%C3%A9finir%20une%20graine%20al%C3%A9atoire%20dans%20la%20fonction%20Random%20Index%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216230%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'avais%20tort%20lorsque%20j'ai%20d%C3%A9clar%C3%A9%20qu'il%20n'existait%20aucun%20moyen%20de%20d%C3%A9finir%20la%20valeur%20de%20d%C3%A9part%20d'un%20index%20al%C3%A9atoire%20()%3B%20La%20fonction%20Random%20Reset()%20fera%20le%20travail%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%3ERe%20%3A%20Comment%20puis-je%20d%C3%A9finir%20une%20graine%20al%C3%A9atoire%20dans%20la%20fonction%20Random%20Index%20%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%3EJe%20ne%20crois%20pas%20que%20vous%20puissiez%20d%C3%A9finir%20la%20graine%20pour%20Random%20Index.Cependant%2C%20vous%20pouvez%20g%C3%A9n%C3%A9rer%20une%20seule%20fois%20la%20matrice%20dont%20vous%20avez%20besoin%2C%20puis%20l'enregistrer%20dans%20un%20fichier%20texte.Vous%20pouvez%20ensuite%20lire%20la%20matrice%20%C3%A0%20partir%20du%20fichier%20texte%20au%20d%C3%A9but%20de%20votre%20script%20et%20d%C3%A9finir%20la%20matrice%20de%20cette%20fa%C3%A7on.Voici%20une%20illustration%20simple%20de%20la%20cr%C3%A9ation%20d'une%20matrice%2C%20de%20son%20enregistrement%20dans%20un%20fichier%20texte%2C%20puis%20de%20la%20mani%C3%A8re%20de%20la%20r%C3%A9cup%C3%A9rer.%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%3EVous%20pouvez%20%C3%A9galement%20cr%C3%A9er%20un%20tableau%20de%20donn%C3%A9es%20avec%20les%20valeurs%20matricielles%20dans%20une%20colonne%2C%20enregistrer%20le%20tableau%20de%20donn%C3%A9es.Ensuite%2C%20si%20n%C3%A9cessaire%2C%20ouvrez%20le%20tableau%20enregistr%C3%A9%20et%20lisez%20les%20valeurs%20de%20la%20colonne%20dans%20une%20matrice.%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%3ERe%20%3A%20Comment%20puis-je%20d%C3%A9finir%20une%20graine%20al%C3%A9atoire%20dans%20la%20fonction%20Random%20Index%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-215810%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'ai%20trouv%C3%A9%20un%20compl%C3%A9ment%26nbsp%3B%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%3EPour%20des%20valeurs%20simples%26nbsp%3B%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%3EPour%20un%20objet%20%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%3EPour%20une%20plateforme%20%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%3EEssayez%20Random%20Seed%20dans%20l'index%20de%20script%20pour%20plus%20d'informations%26nbsp%3B%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