summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/tool/interpr3.cxx24
-rw-r--r--sc/source/core/tool/interpr4.cxx4
-rw-r--r--sc/source/filter/excel/xlformula.cxx4
-rw-r--r--sc/source/filter/oox/formulabase.cxx4
-rw-r--r--sc/source/ui/src/scfuncs.src80
6 files changed, 112 insertions, 6 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index d5305d1aec31..813fb1b13b90 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -790,6 +790,7 @@ void ScQuartile();
void ScNormInv();
void ScSNormInv();
void ScConfidence();
+void ScConfidenceT();
void ScTrimMean();
void ScProbability();
void ScCorrel();
@@ -819,6 +820,7 @@ double GetUpRegIGamma(double fA,double fX); // upper regularized incomplete
double GetGammaDistPDF(double fX, double fAlpha, double fLambda);
// cumulative distribution function; fLambda is "scale" parameter
double GetGammaDist(double fX, double fAlpha, double fLambda);
+double GetTInv( double fAlpha, double fSize );
public:
ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 3f665f30c7e4..6272792be0a5 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2120,13 +2120,17 @@ void ScInterpreter::ScTInv()
PushIllegalArgument();
return;
}
+ PushDouble( GetTInv( fP, fDF ) );
+};
+double ScInterpreter::GetTInv( double fAlpha, double fSize )
+{
bool bConvError;
- ScTDistFunction aFunc( *this, fP, fDF );
- double fVal = lcl_IterateInverse( aFunc, fDF*0.5, fDF, bConvError );
+ ScTDistFunction aFunc( *this, fAlpha, fSize );
+ double fVal = lcl_IterateInverse( aFunc, fSize * 0.5, fSize, bConvError );
if (bConvError)
SetError(errNoConvergence);
- PushDouble(fVal);
+ return( fVal );
}
class ScFDistFunction : public ScDistFunc
@@ -2247,6 +2251,20 @@ void ScInterpreter::ScConfidence()
}
}
+void ScInterpreter::ScConfidenceT()
+{
+ if ( MustHaveParamCount( GetByte(), 3 ) )
+ {
+ double n = ::rtl::math::approxFloor(GetDouble());
+ double sigma = GetDouble();
+ double alpha = GetDouble();
+ if (sigma <= 0.0 || alpha <= 0.0 || alpha >= 1.0 || n < 1.0)
+ PushIllegalArgument();
+ else
+ PushDouble( sigma * GetTInv( 1 - alpha / 2, n - 1 ) / sqrt( n ) );
+ }
+}
+
void ScInterpreter::ScZTest()
{
sal_uInt8 nParamCount = GetByte();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 53fdcd2fa10b..f17f8470a3ad 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4143,7 +4143,9 @@ StackVar ScInterpreter::Interpret()
case ocQuartile : ScQuartile(); break;
case ocNormInv : ScNormInv(); break;
case ocSNormInv : ScSNormInv(); break;
- case ocConfidence : ScConfidence(); break;
+ case ocConfidence :
+ case ocConfidence_N : ScConfidence(); break;
+ case ocConfidence_T : ScConfidenceT(); break;
case ocTrimMean : ScTrimMean(); break;
case ocProb : ScProbability(); break;
case ocCorrel : ScCorrel(); break;
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 6d159bd8cabc..9f0184325d1d 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -443,7 +443,9 @@ static const XclFunctionInfo saFuncTable_2010[] =
EXC_FUNCENTRY_V_VR( ocChiSqInv_MS, 2, 2, 0, "CHISQ.INV" ),
EXC_FUNCENTRY_V_VR( ocChiDist_MS, 2, 2, 0, "CHISQ.DIST.RT" ),
EXC_FUNCENTRY_V_VR( ocChiInv_MS, 2, 2, 0, "CHISQ.INV.RT" ),
- EXC_FUNCENTRY_V_VR( ocChiTest_MS, 2, 2, 0, "CHISQ.TEST" )
+ EXC_FUNCENTRY_V_VR( ocChiTest_MS, 2, 2, 0, "CHISQ.TEST" ),
+ EXC_FUNCENTRY_V_VR( ocConfidence_N, 3, 3, 0, "CONFIDENCE.NORM" ),
+ EXC_FUNCENTRY_V_VR( ocConfidence_T, 3, 3, 0, "CONFIDENCE.T" )
};
/** Functions new in Excel 2013.
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 9ffda5b3129f..09838b3623be 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -761,7 +761,9 @@ static const FunctionData saFuncTable2010[] =
{ "COM.MICROSOFT.CHISQ.INV", "CHISQ.INV", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "COM.MICROSOFT.CHISQ.DIST.RT", "CHISQ.DIST.RT", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
{ "COM.MICROSOFT.CHISQ.INV.RT", "CHISQ.INV.RT", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW },
- { "COM.MICROSOFT.CHISQ.TEST", "CHISQ.TEST", NOID, NOID, 2, 2, V, { VA }, FUNCFLAG_MACROCALL_NEW }
+ { "COM.MICROSOFT.CHISQ.TEST", "CHISQ.TEST", NOID, NOID, 2, 2, V, { VA }, FUNCFLAG_MACROCALL_NEW },
+ { "COM.MICROSOFT.CONFIDENCE.NORM", "CONFIDENCE.NORM", NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALL_NEW },
+ { "COM.MICROSOFT.CONFIDENCE.T", "CONFIDENCE.T", NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALL_NEW }
};
/** Functions new in Excel 2013.
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 60d8a8e1d5dd..e41cfab3210a 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -7610,6 +7610,86 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
Text [ en-US ] = "The size of the population." ;
};
};
+ // -=*# Resource for function CONFIDENCE.NORM #*=-
+ Resource SC_OPCODE_CONFIDENCE_N
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a (1 alpha) confidence interval for a normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CONFIDENCE_N );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The level of the confidence interval." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The standard deviation of the population." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "size" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The size of the population." ;
+ };
+ };
+ // -=*# Resource for function CONFIDENCE.T #*=-
+ Resource SC_OPCODE_CONFIDENCE_T
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a (1 alpha) confidence interval for a Student's t distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CONFIDENCE_T );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The level of the confidence interval." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The standard deviation of the population." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "size" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The size of the population." ;
+ };
+ };
// -=*# Resource for function GTEST #*=-
Resource SC_OPCODE_Z_TEST
{