Effacer les filtres
Effacer les filtres

How can I easily give all of my simulink random number generators different but controlable seeds?

4 vues (au cours des 30 derniers jours)
Simulink random number blocks, as one would expect, output the exact same stream of numbers given the same seed. This becomes problematic if you have a large number of sensors and/or actuators, all with error represented as functions of random numbers. If you provide all random number generators with the same seed, all of your sensor errors will peak and trough in unison which is a pathalogical case. Conversely, if you seed random number generators with a random value, your sim is no longer repeatable.
The solution would seem to be to seed all of your blocks with a some global seed plus a value unique to each block. That way the sim is repeateable, all blocks provide "unique" random number streams, and you can easily vary the random number streams for monte carlo runs by simply varying the global seed value.
My question is, what is the best way to give each random number block its unique value. The brute force method of hand picking a number becomes tedious and difficult to keep track of pretty quickly. I forsee lots of complications here. For example, what do you do if you have a library block you use multiple instances of? Has anybody tackled this in a way they are happy with?

Réponses (1)

Yogananda Jeppu
Yogananda Jeppu le 15 Fév 2019
I use an array of seed say 10x1. In a for loop i use the datetime to pick a random seed and assign it to the seed array. This gets stored with the simulation data or analysis data for reproducibility. each random number input block has this seedx(1), seedx(2) ... Brute force but works for monte carlo. I have not done this but perhaps a variable pause can be used in the for loop to pick random seeds as time.
  1 commentaire
Joel Handy
Joel Handy le 15 Fév 2019
Thats a good suggestion similar to what I have settled on for the time being.
Right now I have a global seed, and a series of subsytem seeds (eg. 100, 200, 300, 400, etc.). Then each random number generator see is global seed + subsystem seed + block seed where the block seed is just incremented each time I add a random number gerator.
That way all I need to do to change all of the seeds is change the global seed and I still have a systematic way of maintaining and assigning unique seeds to each block.
Its still brute force and prone to hard to trace error in my opinion. I'm not sure there is away around that though without and additional option being added to the random number blocks.

Connectez-vous pour commenter.

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by