Cancel
Showing results for 
Search instead for 
Did you mean: 

Irritating application of real and integer values

Builder
Builder

Hi guys!

 

I am hugely irritated by the usage of real and integer values in PlantSimulation. First of all I do not see, why an integer division in PlantSimulation ("//") is restricted to integer values by default, but that's one thing.

 

Let's have a look at the following small piece of code:

is
do
    local v1 := z_uniform(1, 1, 100);
    local v2 := floor(v1);
    v2 := v2 // 10;
end;

Even when the commands "floor()" and "ceil()" are looking for the next lower / upper integer value, the result is returned as a real value. I know it is mentioned in the manual, but I do not see any sense in that.

 

On the other hand, PlantSimulation is clearly distinguishing between integer and real results with respect to the implemented probability distributions. z_uniform and z_negexp are returining real values while z_binomial or z_poisson are explicitly returning integer results.

 

Maybe to rethink the approach to achieve a higher consistency?

3 REPLIES

Re: Irritating application of real and integer values

Siemens Phenom Siemens Phenom
Siemens Phenom
  1. floor and ceil can be called with an argument that is out of the integer range. You are right that "floor(3.3)" could return the integer value 3. But "floor(pi*1e9)" would be out of the integer range and must therefore return a real value. We decided that it is better to always return the same data type.
    If you want to convert a real value into an integer value, simply assign that real value to a local integer variable:
    local v2 : integer := floor(v1);

  2. You are wrong about z_poisson. It returns a real value, like it should. z_binomial on the other hand is a discrete distribution, that generates integer values. So why should it return a real value?
_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Irritating application of real and integer values

Builder
Builder

Just have a look into the manual or help-file concerning the z_poisson distribution!

 

Citing: "The return value k of the distribution is the number of events (integer)."

Re: Irritating application of real and integer values

Siemens Phenom Siemens Phenom
Siemens Phenom

I was wrong. Both, z_poisson and z_binomial, are discrete distributions that only generate "integer" values. The values are returned as data type real, so that all z_-functions return the same data type for consistency reasons. That's a matter of argument, but I don't think we will change it.

 

The online-help is in fact misleading. With the term "integer" we probably wanted to express that the distributions only return natural numbers (positive values without places after the decimal point). We will change the online-help and explain this better.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.