To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=75279


User regina changed the following:

                What    |Old value                 |New value
================================================================================
              Issue type|ENHANCEMENT               |PATCH
--------------------------------------------------------------------------------




------- Additional comments from [email protected] Sun Feb 20 21:25:17 
+0000 2011 -------
Problems and solutions
======================
For illustrations see the attached document "testCases.ods".

1.
Getting zero in GetBetaDist doesn't come from lcl_GetBetaHelperContFrac but
because of missing an underflow case. I have added that case.

2.
When q^n and p^n both underflow, the value of BINOMDIST or B respectively is
calculated by approximation with beta distribution. This gives an accuracy of
about 13 decimal digits. This is the really new part in my patch. [Sheet "no 
value"]

3.
When p is near 1 then q=1-p has severe cancellation errors. But nothing can be
done, because when the interpreter gets the value p it is already in binary
double and the correct decimal value cannot be reconstructed. [Sheet "small n"]

4.
The current solution has a line fSum = 1.0-fFactor and than subtracts values in
a loop. This leads to errors, when fFactor< machine epsilon. I detect this case
and use sum up instead. [Sheet "constant value"]

5.
The sum up parts can result in values greater than 1. Such values are impossible
for cumulative distribution functions. I force the value to 1 in those cases.
[Sheet "illegal value"]

6.
The mass function is used inside BINOMDIST and in B. Therefore I separate it
into a method. It cannot be a local function because it uses GetBetaDistPDF.

7.
Summing up values of a range is used inside B and inside BINOMDIST. Therefore I
separate is into the local function lcl_GetBinomDistRange

8.
I have changed ULONG (now sal_uLong) to sal_int32. This will work-and has until
now-, because higher values of n will not reach the for-loop because p^n and q^n
will underflow.

9.
The current version calculates with denormalized values of fFactor. This gives
wrong results for fFactor near zero. I use the threshold
::std::numeric_limits<double>::min() instead. [Sheet "B range"]

10.
Calculations near the thresholds ::std::numeric_limits<double>::min() and
fMachEps might not be optimal. But I think, that it is not worth to detect
whether for example 1E-308 would be a better threshold than
::std::numeric_limits<double>::min().

11.
Calculation of cases B(n;p;n-k;n) are wrong in case q^n underflow. In this cases
the summand p^n is missing. I have rewritten the loops and initializations in
lcl_GetBinomDistRange. I use:
sum from j=xs to xe {(n choose j) * (q/p)^(n-j) * p^n}
=sum from j=xs to xe {(n choose n-j) * (q/p)^(n-j) * p^n}  substitute i=n-j
=sum from i=n-xe to n-xs { (n choose i) * (q/p)^i * p^n}
[Sheet "B range"]

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to