fdo#71008 add Excel 2010 functions BETA.DEST and BETA.INV
Change-Id: I65863031cc2795713bf80c17dfc787e2700a556a Reviewed-on: https://gerrit.libreoffice.org/6505 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
committed by
Eike Rathke
parent
e44335abe0
commit
6d2f42199c
@@ -335,6 +335,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
|
||||
String SC_OPCODE_TABLE_OP { Text = "MULTIPLE.OPERATIONS" ; };
|
||||
String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; };
|
||||
String SC_OPCODE_BETA_INV { Text = "BETAINV" ; };
|
||||
String SC_OPCODE_BETA_DIST_MS { Text = "COM.MICROSOFT.BETA.DIST" ; };
|
||||
String SC_OPCODE_BETA_INV_MS { Text = "COM.MICROSOFT.BETA.INV" ; };
|
||||
String SC_OPCODE_WEEK { Text = "ISOWEEKNUM" ; };
|
||||
String SC_OPCODE_EASTERSUNDAY { Text = "ORG.OPENOFFICE.EASTERSUNDAY" ; };
|
||||
String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; };
|
||||
@@ -689,6 +691,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
|
||||
String SC_OPCODE_TABLE_OP { Text = "TABLE" ; };
|
||||
String SC_OPCODE_BETA_DIST { Text = "BETADIST" ; };
|
||||
String SC_OPCODE_BETA_INV { Text = "BETAINV" ; };
|
||||
String SC_OPCODE_BETA_DIST_MS { Text = "BETA.DIST" ; };
|
||||
String SC_OPCODE_BETA_INV_MS { Text = "BETA.INV" ; };
|
||||
String SC_OPCODE_WEEK { Text = "WEEKNUM" ; };
|
||||
String SC_OPCODE_EASTERSUNDAY { Text = "EASTERSUNDAY" ; };
|
||||
String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; };
|
||||
@@ -1904,6 +1908,14 @@ Resource RID_STRLIST_FUNCTION_NAMES
|
||||
{
|
||||
Text [ en-US ] = "BETAINV" ;
|
||||
};
|
||||
String SC_OPCODE_BETA_DIST_MS
|
||||
{
|
||||
Text [ en-US ] = "BETA.DIST" ;
|
||||
};
|
||||
String SC_OPCODE_BETA_INV_MS
|
||||
{
|
||||
Text [ en-US ] = "BETA.INV" ;
|
||||
};
|
||||
String SC_OPCODE_WEEK
|
||||
{
|
||||
Text [ en-US ] = "WEEKNUM" ;
|
||||
|
||||
@@ -414,8 +414,10 @@
|
||||
#define SC_OPCODE_ST_DEV_S 416
|
||||
#define SC_OPCODE_VAR_P_MS 417
|
||||
#define SC_OPCODE_VAR_S 418
|
||||
#define SC_OPCODE_BETA_DIST_MS 419
|
||||
#define SC_OPCODE_BETA_INV_MS 420
|
||||
|
||||
#define SC_OPCODE_STOP_2_PAR 419 /* last function with two or more parameters' OpCode + 1 */
|
||||
#define SC_OPCODE_STOP_2_PAR 421 /* last function with two or more parameters' OpCode + 1 */
|
||||
#define SC_OPCODE_STOP_FUNCTION SC_OPCODE_STOP_2_PAR /* last function's OpCode + 1 */
|
||||
#define SC_OPCODE_LAST_OPCODE_ID (SC_OPCODE_STOP_FUNCTION - 1) /* last OpCode */
|
||||
|
||||
|
||||
@@ -378,6 +378,8 @@ enum OpCodeEnum
|
||||
ocTableOp = SC_OPCODE_TABLE_OP,
|
||||
ocBetaDist = SC_OPCODE_BETA_DIST,
|
||||
ocBetaInv = SC_OPCODE_BETA_INV,
|
||||
ocBetaDist_MS = SC_OPCODE_BETA_DIST_MS,
|
||||
ocBetaInv_MS = SC_OPCODE_BETA_INV_MS,
|
||||
// Bit functions
|
||||
ocBitAnd = SC_OPCODE_BITAND,
|
||||
ocBitOr = SC_OPCODE_BITOR,
|
||||
|
||||
@@ -684,5 +684,7 @@
|
||||
#define HID_FUNC_ST_DEV_S "SC_HID_FUNC_ST_DEV_S"
|
||||
#define HID_FUNC_VAR_P_MS "SC_HID_FUNC_VAR_P_MS"
|
||||
#define HID_FUNC_VAR_S "SC_HID_FUNC_VAR_S"
|
||||
#define HID_FUNC_BETADIST_MS "SC_HID_FUNC_BETADIST_MS"
|
||||
#define HID_FUNC_BETAINV_MS "SC_HID_FUNC_BETAINV_MS"
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -2357,6 +2357,8 @@ void Test::testFunctionLists()
|
||||
"AVERAGEIF",
|
||||
"AVERAGEIFS",
|
||||
"B",
|
||||
"BETA.DIST",
|
||||
"BETA.INV",
|
||||
"BETADIST",
|
||||
"BETAINV",
|
||||
"BINOMDIST",
|
||||
|
||||
@@ -754,6 +754,7 @@ void ScChiSqDist(); // returns left tail or density
|
||||
void ScChiSqInv(); //invers to CHISQDIST
|
||||
void ScWeibull();
|
||||
void ScBetaDist();
|
||||
void ScBetaDist_MS();
|
||||
void ScFInv();
|
||||
void ScTInv();
|
||||
void ScChiInv();
|
||||
|
||||
@@ -1040,6 +1040,67 @@ 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()
|
||||
*/
|
||||
void ScInterpreter::ScBetaDist_MS()
|
||||
{
|
||||
sal_uInt8 nParamCount = GetByte();
|
||||
if ( !MustHaveParamCount( nParamCount, 4, 6 ) )
|
||||
return;
|
||||
double fLowerBound, fUpperBound;
|
||||
double alpha, beta, x;
|
||||
bool bIsCumulative;
|
||||
if (nParamCount == 6)
|
||||
fUpperBound = GetDouble();
|
||||
else
|
||||
fUpperBound = 1.0;
|
||||
if (nParamCount >= 4)
|
||||
fLowerBound = GetDouble();
|
||||
else
|
||||
fLowerBound = 0.0;
|
||||
bIsCumulative = GetBool();
|
||||
beta = GetDouble();
|
||||
alpha = GetDouble();
|
||||
x = GetDouble();
|
||||
double fScale = fUpperBound - fLowerBound;
|
||||
if (fScale <= 0.0 || alpha <= 0.0 || beta <= 0.0)
|
||||
{
|
||||
PushIllegalArgument();
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void ScInterpreter::ScPhi()
|
||||
{
|
||||
PushDouble(phi(GetDouble()));
|
||||
|
||||
@@ -4167,7 +4167,9 @@ StackVar ScInterpreter::Interpret()
|
||||
case ocFInv : ScFInv(); break;
|
||||
case ocLogInv : ScLogNormInv(); break;
|
||||
case ocBetaDist : ScBetaDist(); break;
|
||||
case ocBetaInv : ScBetaInv(); break;
|
||||
case ocBetaDist_MS : ScBetaDist_MS(); break;
|
||||
case ocBetaInv :
|
||||
case ocBetaInv_MS : ScBetaInv(); break;
|
||||
case ocExternal : ScExternal(); break;
|
||||
case ocTableOp : ScTableOp(); break;
|
||||
case ocStop : break;
|
||||
|
||||
@@ -412,7 +412,9 @@ static const XclFunctionInfo saFuncTable_2010[] =
|
||||
EXC_FUNCENTRY_V_RX( ocStDevP_MS, 1, MX, 0, "STDEV.P" ),
|
||||
EXC_FUNCENTRY_V_RX( ocStDevS, 1, MX, 0, "STDEV.S" ),
|
||||
EXC_FUNCENTRY_V_RX( ocVarP_MS, 1, MX, 0, "VAR.P" ),
|
||||
EXC_FUNCENTRY_V_RX( ocVarS, 1, MX, 0, "VAR.S" )
|
||||
EXC_FUNCENTRY_V_RX( ocVarS, 1, MX, 0, "VAR.S" ),
|
||||
EXC_FUNCENTRY_V_VR( ocBetaDist_MS, 4, 6, 0, "BETA.DIST" ),
|
||||
EXC_FUNCENTRY_V_VR( ocBetaInv_MS, 3, 5, 0, "BETA.INV" )
|
||||
};
|
||||
|
||||
/** Functions new in Excel 2013.
|
||||
|
||||
@@ -751,7 +751,9 @@ static const FunctionData saFuncTable2010[] =
|
||||
{ "COM.MICROSOFT.STDEV.P", "STDEV.P", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
|
||||
{ "COM.MICROSOFT.STDEV.S", "STDEV.S", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
|
||||
{ "COM.MICROSOFT.VAR.P", "VAR.P" , NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
|
||||
{ "COM.MICROSOFT.VAR.S", "VAR.S", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW }
|
||||
{ "COM.MICROSOFT.VAR.S", "VAR.S", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW },
|
||||
{ "COM.MICROSOFT.BETA.DIST", "BETA.DIST" , NOID, NOID, 4, 6, V, { VR }, FUNCFLAG_MACROCALL_NEW },
|
||||
{ "COM.MICROSOFT.BETA.INV", "BETA.INV", NOID, NOID, 3, 5, V, { VR }, FUNCFLAG_MACROCALL_NEW }
|
||||
};
|
||||
|
||||
/** Functions new in Excel 2013.
|
||||
|
||||
@@ -6728,6 +6728,126 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
|
||||
{
|
||||
Text [ en-US ] = "The final value for the value interval of the distribution." ;
|
||||
};
|
||||
};
|
||||
// -=*# Resource for function BETA.DIST #*=-
|
||||
Resource SC_OPCODE_BETA_DIST_MS
|
||||
{
|
||||
String 1 // Description
|
||||
{
|
||||
Text [ en-US ] = "Values of the beta distribution." ;
|
||||
};
|
||||
ExtraData =
|
||||
{
|
||||
0;
|
||||
ID_FUNCTION_GRP_STATISTIC;
|
||||
U2S( HID_FUNC_BETADIST_MS );
|
||||
6; 0; 0; 0; 0; 1; 1;
|
||||
0;
|
||||
};
|
||||
String 2 // Name of Parameter 1
|
||||
{
|
||||
Text [ en-US ] = "number" ;
|
||||
};
|
||||
String 3 // Description of Parameter 1
|
||||
{
|
||||
Text [ en-US ] = "The value for which the beta distribution is to be calculated." ;
|
||||
};
|
||||
String 4 // Name of Parameter 2
|
||||
{
|
||||
Text [ en-US ] = "alpha" ;
|
||||
};
|
||||
String 5 // Description of Parameter 2
|
||||
{
|
||||
Text [ en-US ] = "The Alpha parameter of the Beta distribution." ;
|
||||
};
|
||||
String 6 // Name of Parameter 3
|
||||
{
|
||||
Text [ en-US ] = "beta" ;
|
||||
};
|
||||
String 7 // Description of Parameter 3
|
||||
{
|
||||
Text [ en-US ] = "The Beta parameter of the Beta distribution." ;
|
||||
};
|
||||
String 8 // Name of Parameter 4
|
||||
{
|
||||
Text [en-US ] = "Cumulative" ;
|
||||
};
|
||||
String 9 // Description of Parameter 4
|
||||
{
|
||||
Text [ en-US ] = "0 or FALSE for probability density function, any other value or TRUE or omitted for cumulative distribution function.";
|
||||
};
|
||||
String 10 // Name of Parameter 5
|
||||
{
|
||||
Text [ en-US ] = "Start" ;
|
||||
};
|
||||
String 11 // Description of Parameter 5
|
||||
{
|
||||
Text [ en-US ] = "The starting value for the value interval of the distribution." ;
|
||||
};
|
||||
String 12 // Name of Parameter 6
|
||||
{
|
||||
Text [ en-US ] = "End" ;
|
||||
};
|
||||
String 13 // Description of Parameter 6
|
||||
{
|
||||
Text [ en-US ] = "The final value for the value interval of the distribution." ;
|
||||
};
|
||||
};
|
||||
// -=*# Resource for function BETA.INV #*=-
|
||||
Resource SC_OPCODE_BETA_INV_MS
|
||||
{
|
||||
String 1 // Description
|
||||
{
|
||||
Text [ en-US ] = "Values of the inverse beta distribution." ;
|
||||
};
|
||||
ExtraData =
|
||||
{
|
||||
0;
|
||||
ID_FUNCTION_GRP_STATISTIC;
|
||||
U2S( HID_FUNC_BETAINV_MS );
|
||||
5; 0; 0; 0; 1; 1;
|
||||
0;
|
||||
};
|
||||
String 2 // Name of Parameter 1
|
||||
{
|
||||
Text [ en-US ] = "number" ;
|
||||
};
|
||||
String 3 // Description of Parameter 1
|
||||
{
|
||||
Text [ en-US ] = "The probability value for which the inverse beta distribution is to be calculated." ;
|
||||
};
|
||||
String 4 // Name of Parameter 2
|
||||
{
|
||||
Text [ en-US ] = "alpha" ;
|
||||
};
|
||||
String 5 // Description of Parameter 2
|
||||
{
|
||||
Text [ en-US ] = "The Alpha parameter of the Beta distribution." ;
|
||||
};
|
||||
String 6 // Name of Parameter 3
|
||||
{
|
||||
Text [ en-US ] = "beta" ;
|
||||
};
|
||||
String 7 // Description of Parameter 3
|
||||
{
|
||||
Text [ en-US ] = "The Beta parameter of the Beta distribution." ;
|
||||
};
|
||||
String 8 // Name of Parameter 4
|
||||
{
|
||||
Text [ en-US ] = "Start" ;
|
||||
};
|
||||
String 9 // Description of Parameter 4
|
||||
{
|
||||
Text [ en-US ] = "The starting value for the value interval of the distribution." ;
|
||||
};
|
||||
String 10 // Name of Parameter 5
|
||||
{
|
||||
Text [ en-US ] = "End" ;
|
||||
};
|
||||
String 11 // Description of Parameter 5
|
||||
{
|
||||
Text [ en-US ] = "The final value for the value interval of the distribution." ;
|
||||
};
|
||||
};
|
||||
// -=*# Resource for function WEIBULL #*=-
|
||||
Resource SC_OPCODE_WEIBULL
|
||||
|
||||
Reference in New Issue
Block a user