Kaydet (Commit) 245b6154 authored tarafından Winfried Donkers's avatar Winfried Donkers Kaydeden (comit) Eike Rathke

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/31910Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 0c49ab77
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment