The cdfnor function is inaccurate when x is close to 0.5.
Reported by Michael BAUDIN
-- Bug description --
The cdfnor function can be inaccurate.
The cdfnor function is ill-conditionned when x is close to 0.5.
See the session :
p = 9007199254740983 *2^-54;
q = 1-p;
y = cdfnor("X",0,1,p,q)
e = -1.25231239110229511e-15
(y-e)/e
This produces:
-->(y-e)/e
ans =
1.084021797008589104D-02
meaning that less than 2 digits are accurate.
Wolfram produces the exact result with the expression sqrt(2)*erfinv(2*9007199254740983 *2^-54-1).
On the other hand, Matlab produces a result with less than 9 digits.
>> y = norminv(9007199254740983 *2^-54)
y =
-1.252312392515284e-015
>> e = -1.25231239110229511e-15
e =
-1.252312391102295e-015
>> (y-e)/e
ans =
1.128304185485305e-009
Octave produces the exact result.
octave-3.2.4.exe:1> y = norminv(9007199254740983 *2^-54)
y = -1.2523e-015
octave-3.2.4.exe:2> e = -1.25231239110229511e-15
e = -1.2523e-015
octave-3.2.4.exe:3> (y-e)/e
ans = -0
The consequence of this bug is that, if the erfcinv function uses cdfnor (as suggested in http://bugzilla.scilab.org/show_bug.cgi?id=6365), the erfcinv function is not accurate for x close to 1.
-- Scilab error message --
-- How to reproduce the bug --