summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/interpr3.cxx
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2013-11-17 10:54:37 +0100
committerEike Rathke <erack@redhat.com>2013-11-20 12:25:18 -0600
commit5a1fa549520aad341b1b8cfe59b1e1b6ed3e4164 (patch)
tree893c20737f93ebfa44363f37b159258775e23617 /sc/source/core/tool/interpr3.cxx
parentb3ecd33b45d131e63bff287ae564c4225a946959 (diff)
fdo#71436 add Excel 2010 functions for F-distribution
Added F.DIST.RT, F.INV.RT, F.TEST, which are renamed FDIST, FINV and FTEST and handle the right tail F-distribution. Added F.DIST and F.INV, which are new functions and handle the left tail F-distribution. Change-Id: Ia7fa26a25f3188249f280733d6111951e2600704 Reviewed-on: https://gerrit.libreoffice.org/6701 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/core/tool/interpr3.cxx')
-rw-r--r--sc/source/core/tool/interpr3.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 6272792be0a5..2f534f618249 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1597,6 +1597,33 @@ void ScInterpreter::ScFDist()
PushDouble(GetFDist(fF, fF1, fF2));
}
+void ScInterpreter::ScFDist_LT()
+{
+ if ( !MustHaveParamCount( GetByte(), 4 ) )
+ return;
+ bool bCum = GetBool();
+ double fF2 = ::rtl::math::approxFloor( GetDouble() );
+ double fF1 = ::rtl::math::approxFloor( GetDouble() );
+ double fF = GetDouble();
+ if ( fF < 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10 )
+ {
+ PushIllegalArgument();
+ return;
+ }
+ if ( bCum )
+ {
+ // left tail cumulative distribution
+ PushDouble( 1.0 - GetFDist( fF, fF1, fF2 ) );
+ }
+ else
+ {
+ // probability density function
+ PushDouble( pow( fF1 / fF2, fF1 / 2 ) * pow( fF, ( fF1 / 2 ) - 1 ) /
+ ( pow( ( 1 + ( fF * fF1 / fF2 ) ), ( fF1 + fF2 ) / 2 ) *
+ GetBeta( fF1 / 2, fF2 / 2 ) ) );
+ }
+}
+
void ScInterpreter::ScChiDist()
{
double fResult;
@@ -2168,6 +2195,27 @@ void ScInterpreter::ScFInv()
PushDouble(fVal);
}
+void ScInterpreter::ScFInv_LT()
+{
+ if ( !MustHaveParamCount( GetByte(), 3 ) )
+ return;
+ double fF2 = ::rtl::math::approxFloor(GetDouble());
+ double fF1 = ::rtl::math::approxFloor(GetDouble());
+ double fP = GetDouble();
+ if (fP <= 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10 || fP > 1.0)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ bool bConvError;
+ ScFDistFunction aFunc( *this, ( 1.0 - fP ), fF1, fF2 );
+ double fVal = lcl_IterateInverse( aFunc, fF1*0.5, fF1, bConvError );
+ if (bConvError)
+ SetError(errNoConvergence);
+ PushDouble(fVal);
+}
+
class ScChiDistFunction : public ScDistFunc
{
ScInterpreter& rInt;