Can't understand what rng(seed) does.

33 views (last 30 days)
DM
DM on 20 Apr 2015
Commented: the cyclist on 20 Apr 2015
I have come across this command in matlab. rng(seed). I used the help to understand what its means, and I still don't get it. Can anyone help me understand what it does?
rng Control the random number generator used by RAND, RANDI, and RANDN.
rng(SD) seeds the random number generator using the non-negative
integer SD so that RAND, RANDI, and RANDN produce a predictable
sequence of numbers.
THanks.

Answers (1)

the cyclist
the cyclist on 20 Apr 2015
Edited: the cyclist on 20 Apr 2015
The Random seed Wikipedia page might help you understand.
This page from stackoverflow may also help.
  2 Comments
the cyclist
the cyclist on 20 Apr 2015
Yes. You can think of the pseudorandom numbers from the generator as a long -- very long -- list of numbers that are uncorrelated with each other, and the seed determines where in that list you start.

Sign in to comment.

Categories

Find more on Random Number Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by