I am using AnyLogic for a simulation, and in a function I made, I am creating a custom distribution from a list of observations (integers) which I stored in a database table (some values are 10,12,10,14,16,20,21,23,11,...
).
The problem is that after creating the custom distribution programatically, it returns always the same value from the distribution (14
). I thought that fixing the seed at 0 was causing the problem, so I wrote this code to compute a random seed for each execution and use it to get the random value from the custom distribution :
CustomDistribution dist = new CustomDistribution(leadtimes);
int seed = ThreadLocalRandom.current().nextInt(0, 100 + 1);
traceln("Seed : "+seed);
delay = dist.get(new Random(seed));
In this code, leadtimes
is a list of integer observations, seed
is generated randomly each time, dist
is the custom distribution object, and delay
is the random value that I would like to get.
In short :
How to generate a random value that is different each time from a custom distribution created programatically ?
Aucun commentaire:
Enregistrer un commentaire