Resume from latest Randstream

2 vues (au cours des 30 derniers jours)
Sebastian Thuné
Sebastian Thuné le 18 Avr 2021
Hi,
I am generating some data with matlab over azure. While generating data I use rand.
x = x_limits(1) + rand*(x_limits(2)-x_limits(1));
z = z_limits(1) + rand*(z_limits(2)-z_limits(1));
I usually generate a couple of MB of data (~200k samples) which I then use and perform tests on and then depending on the results from the test I generate more. However I have encountered a problem which is that when starting the script for generating data again It gives me the exact same as the previous generated data file. Even if I use:
rng('shuffle')
I still get a data file containing a lot of the same data. Is there a way in which I can save where my randstream finsihed in a lets say randState.mat file that I can later call when resuming data generator. Basically, picking up where the randstream last was used.
Thanks!

Réponse acceptée

Divija Aleti
Divija Aleti le 21 Avr 2021
Hi Sebastian,
Setting the seed of "rng" to 'shuffle' helps getting different sequence of random numbers after each call to rng, but these sequences are not necessarily independent.
To get independent sequences, consider specifying the "Substream" property of "RandStream" or using "RandStream.create". You can find details of these in the links given below:
For examples for creating multiple streams, refer to the following link:
Hope this helps!
Regards,
Divija
  1 commentaire
Sebastian Thuné
Sebastian Thuné le 21 Avr 2021
Thanks Divija!
My backup plan was to create different streams on x and z. I will give the Multiple streams a shot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by