how to get randomization seed ?

2 views (last 30 days)
Joe
Joe on 30 Nov 2014
Answered: Joe on 2 Dec 2014
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.

Accepted Answer

Peter Perkins
Peter Perkins on 2 Dec 2014
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.

More Answers (1)

Joe
Joe on 2 Dec 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.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!