Why are the random numbers obtained by different invocations to LOGRND() the same?

3 Ansichten (letzte 30 Tage)
I used the LOGRND()[https://www.mathworks.com/help/stats/lognrnd.html] funtion to conduct a Monte Carlo Experiment. I used to two different functions(both are attached below) to call logrnd and stored the results in different mat files. The m-files are run remotely in a node using parallel computing.
However, the random parameters resulting from the two different invocations to logrnd are the same. How is this possible ?
Will using rng('shuffle') before calling logrnd() help ?
Appreciate the help.

Antworten (1)

John Chilleri
John Chilleri am 26 Dez. 2016
Hello,
This is possible because the two different invocations are running off the same initial seed, causing the same values to be generated.
Furthermore, using rng('shuffle') may not solve the problem, as it generates a random seed based on the current time; however, we might be able to get around this by placing a pause(some amount of time) in one of your functions before the use of rng('shuffle').
Hope this helps!

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by