question

Joerg Vogel avatar image
0 Likes"
Joerg Vogel asked Phil BoBo edited

Method to set value ranges in a uniform distribution

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?

FlexSim 16.2.1
distribution parametersuniform
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Phil BoBo edited

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.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeff Nordgren avatar image
0 Likes"
Jeff Nordgren answered

@Jörg Vogel

Jorge,

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

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.