How can I easily give all of my simulink random number generators different but controlable seeds?
3 views (last 30 days)
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?
Yogananda Jeppu on 15 Feb 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.