Why does rand return the same output every time?

I am working on a research project. I downloaded a function called "astupidfunction" from authors'website and that function defines a regression model. I looked inside the function and did not see anything related to random numbers generator. What makes me surprising is that when I run the following codes thousand times
rand(1);
f=astupidfunction(x);
The rand(1) always returns the same number.
What happened when I remove the line "f=astupidfunction(x);" and run rand(1);
I obtained DIFFERENT random numbers.
I guess the reason lies on the function f=astupidfunction(x). I attached the file that contains the function "IWTGP" is the actual name of that stupid function. Anyone can help me or clarify why the above problem happened. In addition how to run
rand(1); f=astupidfunction(x);
to obtain different random numbers ?
Thanks

2 comentarios

Geoff Hayes
Geoff Hayes el 18 de Mayo de 2017
Cuong - have you tried contacting the author of the code? What about the EvalKernel function (defined within your attached code)? Have you looked into that function to see what it is doing?
Peter Perkins
Peter Perkins el 18 de Mayo de 2017
That function contains no random number generator calls at all, so you're not telling the whole story.
I suggest you read the doc about rand, and controlling the random number generator, and figure out what line in your code, or whoever's code, is resetting the generator.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Mayo de 2017

Comentada:

el 18 de Mayo de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by