-- Bug description --
The inverse distribution function provides only 8 accurate digits.
This accuracy issue is for : cdfbet, cdfgam, cdfbin, cdfchi, cdfchin, cdff, cdffnc, cdfnbn, cdfpoi. The cdfnor function is acceptable (but not full accuracy).
The following test comes from a paper by A. Talha Yalta :
"The accuracy of statistical distributions in Microsoft Excel 2007".
Let us consider the inverse beta distribution function.
We can compare the result provided by Scilab and R :
Scilab : 0.2928932175068737486789
R : 0.2928932188134525
Matlab : 0.292893218813453
We see that R, Matlab and Scilab provide the same first 8 digits, but are different from there : Matlab and R give the same result, but not Scilab.
To get these results, we can use the following scripts.
Scilab :
format("v",25)
p = 0.5
q = 1-p
a = 1
b = 2
x = cdfbet("XY",a,b,p,q)
R :
options(digits=20)
qbeta(0.5, 1, 2)
Matlab :
format long
X = betainv(0.5,1,2)
Look at line 105 of cdfbet.f from DCDFLIB :
http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfbet.f;h=a50da8635bc42c7a4753df7fbc17bbbf04ddd42a;hb=HEAD
you see :
PARAMETER (tol=1.0D-8)
This is the relative error which is used to compute the inverse of the beta distribution function.
If you unzip the archive of DCDFLIB from Netlib :
http://www.netlib.org/random/dcdflib.c.tar.gz
and look at the README, you get :
"The zero finder attempts to obtain the answer accurately to about eight decimal
places."
There is the same accuracy limitation in :
* cdfgam : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfgam.f;h=aab74e9c3e07ec55da4dfd20603093371d3a1219;hb=HEAD
* cdfbin : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfbin.f;h=e728e69693b05487320fc37c40a61b8bf633e506;hb=HEAD
* cdfchi : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfchi.f;h=68f881857269319e464851bffa10a4ea23392969;hb=HEAD
* cdfchin : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfchn.f;h=ee4c71cdf1742dae7990f131b10c60490cb7d3ca;hb=HEAD
* cdff : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdff.f;h=17fca8142a028a8cca0a259a15c63d9c5aa2f7c1;hb=HEAD
* cdffnc : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdffnc.f;h=57f62cf94b152cc77c1ccdae923499adef3f5605;hb=HEAD
* cdfnbn : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfnbn.f;h=bc8644f7bdd32ffa2dc2fcc514949f2c91338cd7;hb=HEAD
* cdfpoi : http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/cdfpoi.f;h=cab3bd3e57f4847af9a8a4b88420f3e67b054733;hb=HEAD
The cdfnor function seems to be OK but is not perfect :
http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/statistics/src/dcdflib/dinvnr.f;h=2639ef8ad0718c3d17fdbd8a7b857331ce93b2fe;hb=HEAD
It uses a Newton method with relative precision :
PARAMETER (eps=1.0D-13)
with condition
IF (abs(dx/xcur).LT.eps) GO TO 40
This should allow up to 13 accurate digits. This is not full accuracy, but is only slightly less than the upper bound 17.
-- Scilab error message --
-- How to reproduce the bug --