diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2016-12-09 17:26:17 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-12-12 20:32:38 +0000 |
commit | 5c20348e66b6c8fe88d204ba5b6f01b572334152 (patch) | |
tree | 0b0e570168d9c915d891d93769bcbab32cb3427c /sc | |
parent | 8a800eea613c0f5ad3302136766791dc58880fb3 (diff) |
tdf#104532 handle constraints for NEGBINOM.DIST correctly.
Also changed variable names for easier understanding of their meaning.
Change-Id: Iab558d7d1d9533f2a0c42e3d5f4acecead2e818e
Reviewed-on: https://gerrit.libreoffice.org/31807
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit ccbb0dd8788bf481f398782bf1519cd57c3b2bfb)
Reviewed-on: https://gerrit.libreoffice.org/31908
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 66ca35cb261b..d05c34dc25a3 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -1514,21 +1514,21 @@ void ScInterpreter::ScNegBinomDist_MS() if ( MustHaveParamCount( GetByte(), 4 ) ) { bool bCumulative = GetBool(); - 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 ( s < 1.0 || f < 0.0 || p < 0.0 || p > 1.0 ) PushIllegalArgument(); else { double q = 1.0 - p; if ( bCumulative ) - PushDouble( 1.0 - GetBetaDist( q, x + 1, r ) ); + PushDouble( 1.0 - GetBetaDist( q, f + 1, s ) ); else { - 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 ); } } |