Setting seed in random ('normal')

I am using random('Normal',2,5,T,1) to generate vector of random numbers from normal distribution with mean 2, variance 5. I want to set the seed so that I can get same set of random numbers each time I run the m file. I am using matlab 7.10.0 (R2010a). I have tried with rand('seed',0) command before random('Normal',2,5,T,1) but it does not serve my purpose. Can anyone help me please?

 Respuesta aceptada

the cyclist
the cyclist el 8 de Jul. de 2012
Editada: the cyclist el 8 de Jul. de 2012

1 voto

In that version of MATLAB, I am pretty sure that there are separate streams for rand() and randn(). I think random('Normal',...) effectively uses randn() in its guts. So, I believe you will get what you want if you just use
>> randn('seed',0)

Más respuestas (1)

Luffy
Luffy el 8 de Jul. de 2012
Editada: Walter Roberson el 8 de Jul. de 2012

0 votos

I do not know about seed you r talking about,but if you want to get same sat of random numbers every time do this,
rng('default');
random('Normal',2,5,T,1);
rng('default');
random('Normal',2,5,T,1);
Every time you use random('Normal',2,5,T,1),make sure to put rng('default') before it & u end up with same set f random data every time

5 comentarios

Rabeya
Rabeya el 8 de Jul. de 2012
Editada: Rabeya el 8 de Jul. de 2012
Thanks, but this shows an error message in my version of Matlab: ??? Undefined function or method 'rng' for input arguments of type 'char'.
Luffy
Luffy el 8 de Jul. de 2012
see doc rng
Walter Roberson
Walter Roberson el 8 de Jul. de 2012
rng is newer than R2010a, so Rabeya does not have access to it.
Luffy
Luffy el 8 de Jul. de 2012
Editada: Walter Roberson el 8 de Jul. de 2012
@ Walter: Is there a way to see which functions are not defined in which versions of Matlab in help file/ in forum ??,like rng is not defined in R2010a
Walter Roberson
Walter Roberson el 8 de Jul. de 2012
Sorry, Luffy, there is no known list of which functions are defined in which version. If, though, your profile here is attached to a MATLAB license, then when you look at a documentation page, you can ask to search other releases, and hunt around until you find the version that introduces (or drops) the function.

Iniciar sesión para comentar.

Categorías

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

Productos

Etiquetas

Preguntada:

el 8 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by