how to get randomization seed ?

how to get the randomization seed of an execution without using rng ?
When we use 's=rng;' the seed is set to 0. I want to get seed of execution, so that I can repeat the execution instance which I find as working well.

 Risposta accettata

Peter Perkins
Peter Perkins il 2 Dic 2014

1 voto

Joe, I think you want the random number state, not the seed. RNG will give you both.
You description is a little vague, but I think what you mean is this:
You run some code that involves random numbers. If something interesting happens, you want to be able to rerun it using the same random numbers.
If you save the output of RNG before running the code, then restore the state again using RNG, your code will use the same random numbers again. The first example on the RNG reference page shows how to do this.

Più risposte (1)

Joe
Joe il 2 Dic 2014
Hi Peter,
Thanks for the reply. You got my context exactly. I thought s=rng will set the seed as 0. I didn't know that it would save the current seed. i saw that it is always returning seed as 0.

Categorie

Scopri di più su Random Number Generation in Centro assistenza e File Exchange

Richiesto:

Joe
il 30 Nov 2014

Risposto:

Joe
il 2 Dic 2014

Community Treasure Hunt

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

Start Hunting!

Translated by