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

4 views (last 30 days)
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.

Answers (1)

John Chilleri
John Chilleri on 26 Dec 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!

Categories

Find more on Random Number Generation 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!