[PATCH 1/2] fdo# 40835, 4th parameter for FDIST
Wolfgang Pechlaner
libo at pechlaner.at
Wed Sep 21 10:30:41 PDT 2011
---
sc/source/core/inc/interpre.hxx | 1 +
sc/source/core/tool/interpr3.cxx | 24 +++++++++++++++++++++---
sc/source/ui/src/scfuncs.src | 10 +++++++++-
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index a693f58..5dbbb94 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -716,6 +716,7 @@ double GetChiDist(double fChi, double fDF); // for LEGACY.CHIDIST, returns r
double GetChiSqDistCDF(double fX, double fDF); // for CHISQDIST, returns left tail
double GetChiSqDistPDF(double fX, double fDF); // probability density function
double GetFDist(double x, double fF1, double fF2);
+double GetFDistPDF(double x, double fF1, double fF2);
double GetTDist(double T, double fDF);
double Fakultaet(double x);
double BinomKoeff(double n, double k);
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 728faea..beca279 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -645,13 +645,22 @@ double ScInterpreter::GetLogGamma(double fZ)
double ScInterpreter::GetFDist(double x, double fF1, double fF2)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetFDist" );
+ 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 (GetBetaDist(arg, alpha, beta));
}
+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));
+}
+
double ScInterpreter::GetTDist(double T, double fDF)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetTDist" );
@@ -1558,8 +1567,10 @@ void ScInterpreter::ScTDist()
void ScInterpreter::ScFDist()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScFDist" );
- if ( !MustHaveParamCount( GetByte(), 3 ) )
+ sal_uInt8 nParamCount = GetByte();
+ if ( !MustHaveParamCount( nParamCount, 3, 4))
return;
+ bool bCumulative = nParamCount == 4 ? GetBool() : true;
double fF2 = ::rtl::math::approxFloor(GetDouble());
double fF1 = ::rtl::math::approxFloor(GetDouble());
double fF = GetDouble();
@@ -1568,7 +1579,14 @@ void ScInterpreter::ScFDist()
PushIllegalArgument();
return;
}
- PushDouble(GetFDist(fF, fF1, fF2));
+ if (bCumulative)
+ {
+ PushDouble(GetFDist(fF, fF1, fF2));
+ }
+ else
+ {
+ PushDouble(GetFDistPDF(fF, fF1, fF2));
+ }
}
void ScInterpreter::ScChiDist()
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 8f8bb04..d4e781d 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -6406,7 +6406,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
0;
ID_FUNCTION_GRP_STATISTIC;
U2S( HID_FUNC_FVERT );
- 3; 0; 0; 0;
+ 4; 0; 0; 0; 1;
0;
};
String 2 // Name of Parameter 1
@@ -6433,6 +6433,14 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
{
Text [ en-US ] = "The degrees of freedom in the denominator of the F distribution." ;
};
+ String 8 // Name of Parameter 4
+ {
+ Text [en-US ] = "Cumulative" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "0 or FALSE for probability density function, any other value or TRUE or omitted for cumulative distribution function.";
+ };
};
// -=*# Resource for function FINV #*=-
Resource SC_OPCODE_F_INV
--
1.7.3.4
--------------050604060906070403080202
Content-Type: text/x-patch;
name="0002-fdo-40835-4th-parameter-for-FDIST.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0002-fdo-40835-4th-parameter-for-FDIST.patch"
More information about the LibreOffice
mailing list