Effacer les filtres
Effacer les filtres

Simultaneous generators of entities with the same gamma distribution code and the same seed provide me with different results.

1 vue (au cours des 30 derniers jours)
I want to simultaneously generate several entities with different values ​​for their attributes. I use three generators and program de inter arrival time (dt) the same for each box as you can see below.
persistent rngInit;
if isempty(rngInit)
seed = 12346;
rng(seed);
rngInit = true;
end
% Pattern: Gamma distribution
% a: Scale, b: Shape
a = 300; b = 1;
dt = gamrnd(a, b);
The resul results change abruptly between the first generator giving me an inter arrival of 270, the second of 800 and the third more than a thousand. I have put the block back in Time source: Dialog and put 300 on average. And the results remain. I have repeated the model, at the beginning this error does not occur but over time it is configured like this. It seems that somehow it will save the information and link the generation times of the gamma distribution and each one seems double the previous one.
I have individualized the name of the initiation and the seed for each generator to avoid links that I do not know internally ( example below)
persistent rngInit2;
if isempty(rngInit2)
seed2 = 12346;
rng(seed2);
rngInit2 = true;
end
% Pattern: Gamma distribution
% a: Scale, b: Shape
a2 = 300; b2 = 1;
dt = gamrnd(a2, b2);

Réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by