[PATCH 2/2] fdo# 40835, 4th parameter for FDIST

Wolfgang Pechlaner libo at pechlaner.at
Sat Sep 24 12:31:20 PDT 2011


---
 sc/source/core/tool/interpr3.cxx |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index beca279..adcc7a9 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -645,7 +645,7 @@ double ScInterpreter::GetLogGamma(double fZ)
 
 double ScInterpreter::GetFDist(double x, double fF1, double fF2)
 {
-    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetFDistPDF" );
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetFDist" );
     double arg = fF2/(fF2+fF1*x);
     double alpha = fF2/2.0;
     double beta = fF1/2.0;
@@ -655,10 +655,13 @@ double ScInterpreter::GetFDist(double x, double fF1, double fF2)
 double ScInterpreter::GetFDistPDF(double x, double fF1, double fF2)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetFDistPDF" );
-    double arg = fF2/(fF2+fF1*x);
-    double alpha = fF2/2.0;
-    double beta = fF1/2.0;
-    return (GetBetaDistPDF(arg, alpha, beta));
+    if (x == 0 && fF1 == 1)
+    {
+        SetError(errIllegalArgument);
+        return HUGE_VAL;
+    }
+    double prefix = (1.0 /GetBeta(fF1 / 2.0, fF2 / 2.0)) * pow(fF1 / fF2, fF1/2);
+    return prefix * pow(x, fF1/2 -1) / pow(1.0 + fF1/fF2 * x, (fF1 + fF2) / 2);
 }
 
 double ScInterpreter::GetTDist(double T, double fDF)
-- 
1.7.3.4


--------------050604060906070403080202--


More information about the LibreOffice mailing list