Method to set value ranges in a uniform distribution

Method to set value ranges in a uniform distribution

joerg_vogel_HsH
Mentor Mentor
526 Views
2 Replies
Message 1 of 3

Method to set value ranges in a uniform distribution

joerg_vogel_HsH
Mentor
Mentor

[ FlexSim 16.2.1 ]

In addition to the thread of @David Besson Decide activity by percentage bug? how can we set a range of values without the limit values itself like ]0..100[ or 0 < x < 100 inside the parameters of a uniform distribution?

0 Likes
Accepted solutions (1)
527 Views
2 Replies
Replies (2)
Message 2 of 3

jeff_nordgren
Not applicable

@Jörg Vogel

Jorge,

Have you tried using Global Macros as substitutes for the actual limit values themselves?

0 Likes
Message 3 of 3

philboboADSK
Autodesk
Autodesk
Accepted solution

Although the uniform() command documentation claims to be inclusive, if you actually test it, it isn't. It might theoretically be inclusive, but there are theoretically an infinite number of values between any two decimal values so the probably of actually being the extremes is infinitesimally small (roughly 1 in 2^53 for a double-precision value) such that in actual practice, I don't think it ever returns the extremes.

So you can use use the uniform() distribution to get an exclusive distribution of floating point values, as the example code below shows:

int extremes = 0;
for (int i = 1; i <= 10000000; i++) {
	double num = uniform(0,100);
	if (num == 0 || num == 100) {
		extremes++; // this code will never get hit
	}
}
return extremes; // this will always return 0

If you are using duniform(), then you can add 1 to the beginning or subtract 1 from the end to make it exclusive.

The random values uniform() gives back are unlikely to ever actually equal any specific value in the range, including the extremes, unless that value was explicitly obtained using that pseudo-random number generation and then repeated.



Phil BoBo
Sr. Manager, Software Development