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

1 次查看(过去 30 天)
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);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resource Allocation Modeling 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by