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

tdf#101855 BETA.DIST: apply same constraints as Excel does.

Change-Id: I617146665e72286aef3de35b859ca2e52d039bd8
Reviewed-on: https://gerrit.libreoffice.org/28612Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 1eebbd48
......@@ -1079,10 +1079,10 @@ void ScInterpreter::ScBetaDist()
}
/**
fdo#71008
Microsoft version has parameters in different order
Also, upper and lowerbound are optional and have default values
otherwise, function is identical with ScInterpreter::ScBetaDist()
and different constraints apply.
Basically, function is identical with ScInterpreter::ScBetaDist()
*/
void ScInterpreter::ScBetaDist_MS()
{
......@@ -1096,7 +1096,7 @@ void ScInterpreter::ScBetaDist_MS()
fUpperBound = GetDouble();
else
fUpperBound = 1.0;
if (nParamCount >= 4)
if (nParamCount >= 5)
fLowerBound = GetDouble();
else
fLowerBound = 0.0;
......@@ -1104,35 +1104,20 @@ void ScInterpreter::ScBetaDist_MS()
beta = GetDouble();
alpha = GetDouble();
x = GetDouble();
double fScale = fUpperBound - fLowerBound;
if (fScale <= 0.0 || alpha <= 0.0 || beta <= 0.0)
if (alpha <= 0.0 || beta <= 0.0 || x < fLowerBound || x > fUpperBound)
{
PushIllegalArgument();
return;
}
double fScale = fUpperBound - fLowerBound;
if (bIsCumulative) // cumulative distribution function
{
// special cases
if (x < fLowerBound)
{
PushDouble(0.0); return; //see spec
}
if (x > fUpperBound)
{
PushDouble(1.0); return; //see spec
}
// normal cases
x = (x-fLowerBound)/fScale; // convert to standard form
PushDouble(GetBetaDist(x, alpha, beta));
return;
}
else // probability density function
{
if (x < fLowerBound || x > fUpperBound)
{
PushDouble(0.0);
return;
}
x = (x-fLowerBound)/fScale;
PushDouble(GetBetaDistPDF(x, alpha, beta)/fScale);
return;
......
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