summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-12-12 16:09:04 +0100
committerEike Rathke <erack@redhat.com>2016-12-16 19:16:17 +0000
commit83675eeb30c92a17dd272894df34b89628de0142 (patch)
tree3fa368e293ab56508239bf87a167fbbc30a1dba8
parent976f5101f375304f67ebccb546ea265c08f72404 (diff)
tdf#104581 handle constraints for NEGBINOMDIST in compliance with ODFF1.2.
Also changed varaiable names for easier understanding of their meaning. Change-Id: I7c6f338c04898c7b07ebeb97fb331d51fa691f5b Reviewed-on: https://gerrit.libreoffice.org/31910 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 245b615400904274e264d5051baf63b3613db935) Reviewed-on: https://gerrit.libreoffice.org/32087
-rw-r--r--sc/source/core/tool/interpr3.cxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index d05c34dc25a3..1b6a367d42b5 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1493,17 +1493,17 @@ void ScInterpreter::ScNegBinomDist()
{
if ( MustHaveParamCount( GetByte(), 3 ) )
{
- double p = GetDouble(); // p
- double r = GetDouble(); // r
- double x = GetDouble(); // x
- if (r < 0.0 || x < 0.0 || p < 0.0 || p > 1.0)
+ double p = GetDouble(); // probability
+ double s = ::rtl::math::approxFloor(GetDouble()); // No of successes
+ double f = ::rtl::math::approxFloor(GetDouble()); // No of failures
+ if ((f + s) <= 1.0 || p < 0.0 || p > 1.0)
PushIllegalArgument();
else
{
double q = 1.0 - p;
- double fFactor = pow(p,r);
- for (double i = 0.0; i < x; i++)
- fFactor *= (i+r)/(i+1.0)*q;
+ double fFactor = pow(p,s);
+ for (double i = 0.0; i < f; i++)
+ fFactor *= (i+s)/(i+1.0)*q;
PushDouble(fFactor);
}
}