diff options
author | Winfried Donkers <osc@dci-electronics.nl> | 2013-02-06 19:09:00 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-02-08 09:50:20 +0000 |
commit | df931a5b0f48707e34ebfacb695996198ece8f44 (patch) | |
tree | 517fc845a0fcd123c7837e1ea7563ebdd871733e /sc/source | |
parent | 35cda416ce9c23abc9075ef22068d098017efd55 (diff) |
fdo#60322 add calc function SKEWP as in ODFF v1.2
Change-Id: I4851df1473fc7788af1ac642bb0fb527ec872821
Reviewed-on: https://gerrit.libreoffice.org/2020
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 33 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/parclass.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabase.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 24 |
7 files changed, 62 insertions, 2 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index cd44780dbc62..64d48bea1914 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -762,6 +762,7 @@ void ScHarMean(); void ScGeoMean(); void ScStandard(); void ScSkew(); +void ScSkewp(); void ScMedian(); double GetMedian( ::std::vector<double> & rArray ); double GetPercentile( ::std::vector<double> & rArray, double fPercentile ); diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 1b0e85a20d4c..df78713f6226 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -3038,6 +3038,39 @@ void ScInterpreter::ScSkew() PushDouble(((xcube * fCount) / (fCount - 1.0)) / (fCount - 2.0)); } +//fdo#60322 +void ScInterpreter::ScSkewp() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSkewp" ); + double fSum,fCount,vSum; + std::vector<double> values; + if ( !CalculateSkew( fSum, fCount, vSum, values ) ) + return; + + double fMean = fSum / fCount; + + for ( size_t i = 0; i < values.size(); i++ ) + vSum += ( values[ i ] - fMean ) * ( values[ i ] - fMean ); + + double fStdDevp = sqrt( vSum / fCount ); + double dx = 0.0; + double xcube = 0.0; + + if ( fStdDevp == 0 ) + { + PushIllegalArgument(); + return; + } + + for ( size_t i = 0; i < values.size(); i++ ) + { + dx = ( values[ i ] - fMean ) / fStdDevp; + xcube = xcube + ( dx * dx * dx ); + } + + PushDouble( xcube / fCount ); +} + double ScInterpreter::GetMedian( vector<double> & rArray ) { size_t nSize = rArray.size(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index bc7aa6fbfe14..d7df23fa13bb 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4110,6 +4110,7 @@ StackVar ScInterpreter::Interpret() case ocDevSq : ScDevSq(); break; case ocKurt : ScKurt(); break; case ocSchiefe : ScSkew(); break; + case ocSkewp : ScSkewp(); break; case ocModalValue : ScModalValue(); break; case ocMedian : ScMedian(); break; case ocGeoMean : ScGeoMean(); break; diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 6f3cae07861e..b4187c593d8f 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -163,6 +163,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocRows, {{ Reference }, 1 }}, { ocRSQ, {{ ForceArray, ForceArray }, 0 }}, { ocSchiefe, {{ Reference }, 1 }}, + { ocSkewp, {{ Reference }, 1 }}, { ocSlope, {{ ForceArray, ForceArray }, 0 }}, { ocSmall, {{ Reference, Value }, 0 }}, { ocStDev, {{ Reference }, 1 }}, diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 27cbab0d2670..a96b263a4582 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -459,7 +459,7 @@ static const XclFunctionInfo saFuncTable_2013[] = EXC_FUNCENTRY_V_VR_IMPORT( ocSecantHyp, 1, 1, 0, "SECH" ), EXC_FUNCENTRY_V_RO( ocTable, 0, 1, 0, "SHEET" ), EXC_FUNCENTRY_V_RO( ocTables, 0, 1, 0, "SHEETS" ), - EXC_FUNCENTRY_V_RX( ocNoName, 1, MX, 0, "SKEW.P" ), + EXC_FUNCENTRY_V_RX( ocSkewp, 1, MX, 0, "SKEW.P" ), EXC_FUNCENTRY_V_VR( ocUnichar, 1, 1, 0, "UNICHAR" ), EXC_FUNCENTRY_V_VR( ocUnicode, 1, 1, 0, "UNICODE" ), EXC_FUNCENTRY_V_VR( ocNoName, 1, 1, 0, "WEBSERVICE" ), diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index 623b10548b8a..efe95146b15f 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -810,7 +810,7 @@ static const FunctionData saFuncTable2013[] = { "SECH", "SECH", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, { "SHEET", "SHEET", NOID, NOID, 0, 1, V, { RO }, FUNCFLAG_MACROCALL_NEW }, { "SHEETS", "SHEETS", NOID, NOID, 0, 1, V, { RO }, FUNCFLAG_MACROCALL_NEW }, - { 0/*"SKEWP"*/, "SKEW.P", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW }, + { "SKEWP", "SKEW.P", NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW }, { "UNICHAR", "UNICHAR", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, { "UNICODE", "UNICODE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, { 0, "WEBSERVICE", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALL_NEW }, diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 5f4c54024634..433e6fdb78f9 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -5374,6 +5374,30 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments portraying a sample of the distribution." ; }; }; + // -=*# Resource for function SKEWP #*=- + Resource SC_OPCODE_SKEWP + { + String 1 // Description + { + Text [ en-US ] = "Returns the skewness of a distribution using the population of a random variable." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_STATISTIC; + U2S( HID_FUNC_SKEWP ); + VAR_ARGS; 0; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "number " ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments portraying the population." ; + }; + }; // -=*# Resource for function KURT #*=- Resource SC_OPCODE_KURT { |