Condition errorhello
I'm trying to do a delta check between neighboring cells value on the same column.
For( i = 1, i <= N Row( dtB ), i++,
If(
i == 1,
If( Abs( :Delta[i] - :Delta[i + 1] ) <= 0.1,
dtB:Check[i] = "Pass",
dtB:Check[i] = "Fail"
),
i == N Row( dtB ),
If( Abs( :Delta[i] - :Delta[i - 1] ) <= 0.1,
dtB:Check[i] = "Pass",
dtB:Check[i] = "Fail"
),
If( Abs( :Delta[i] - :Delta[i + 1] ) <= 0.1 | Abs( :Delta[i] - :Delta[i - 1] ) <= 0.1,
dtB:Check[i] = "Pass",
dtB:Check[i] = "Fail"
)
)
);
i get this result
but line 5 should not fail
when I check it thru the log it seems like a bug or I'm missing something
appreciate your inputs
i
/*:
5
//:*/
:Delta[i]
/*:
0.3
//:*/
:Delta[i+1]
/*:
0.4
//:*/
abs(:Delta[i] - :Delta[i+1])
/*:
0.1
//:*/
abs(:Delta[i] - :Delta[i+1]) <= 0.1
/*:
0
Consumer and Market ResearchQuality and Process EngineeringRe: Condition error0.1 is a repeating fraction in binary. In IEEE floating point, it is rounded at 52 or 53 bits, so it must be either a bit too big or a bit too small.
Good binary fractions are sums of 1/2, 1/4, 1/8, 1/16, 1/32, ... 1/2^53 which are the individual bits of the fraction.
Sometimes the "bit too big" or "bit too small" works out the way you want, and sometimes not.
The second example shows an epsilon chosen for numbers near 1, which have about 14 places after the decimal (thus 1e-12).
If( .3 - .2 == .1, // "no"
"yes"
, // else
"no"
);
If( Abs( (.3 - .2) - .1 ) < 1e-12, // "yes"
"yes"
, // else
"no"
);
Old post
Re: Condition errorit's not an issue for me, i like to do that
Re: Condition errorThe issue is that the difference from minus .4 to a positive .3 is .7. The Absolute of the values are taken after the calculation!
Re: Condition errorJMP Development confirmed that this is simply a finite precision numerical problem. Users are disturbed by floating point numbers that do not follow the math (e.g., subtraction). JMP tries to present the result as it is expected, but not the actual result in cases like yours (i.e., 0.4 - 0.3). They suggested also using this approach if you want a better view of the actual result:
Format( 0.1, "Fixed Dec", 20, 22 );
Format( 0.4-0.3, "Fixed Dec", 20, 22 );
Re: Condition errorThat's your basic floating point roundoff error. Add an epsilon and it works:
Deltai = 0.3;
Deltai1 = 0.4;
epsilon = .000000001;
print(abs(Deltai - Deltai1)); // = 0.1;
print(abs(Deltai - Deltai1) <= 0.1);
print(abs(Deltai - Deltai1) <= 0.1 + epsilon);
From the log:
0.1
0
1
Re: Condition errorOne more thing to check would be the difference between diff and 0.1
diff - 0.1 = 2.77555756156289e-17;
so floating number accuracy "problem"?
Round(diff, 1) == Round(0.1, 1) = 1;
Re: Condition errorI confirm this error with the follow code (view results in Log):
/* Abs( 0.4 - 0.3) == 0.1; returns 0 or false */
y = 0.1; x1 = 0.4; x2 = 0.3; diff = x1 - x2;
Show( y, x1, x2, diff, diff == 0.1 );
Re: Condition errorsorry, didn't get it.
i = 5;
:Delta[i] = 0.3;
:Delta[i+1] = 0.4;
abs(:Delta[i] - :Delta[i+1]) = 0.1;
// but
abs(:Delta[i] - :Delta[i+1]) <= 0.1 // give me 0
why is that? also == give me 0, >= give 1.
Re: Condition errorI like to check the cell value matching (up to 0.1) from both "sides" n+1 and n-1 in this column. 1st and last rows on one side.
thank you
Re: Condition errorabs(-0.4 - 0.3 ) = 0.7
abs(-0.4) - abs(0.3) = 0.1
Re: Condition errorIf I understand what you are trying to do, then this simplified version might work:
For Each Row(
dtB:Check = If( Abs( :Delta - Lag(:Delta) ) <= 0.1, "Pass", "Fail" );
);