summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/interpr3.cxx
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2013-10-04 17:56:04 +0200
committerEike Rathke <erack@redhat.com>2013-10-18 19:04:09 +0000
commitccbebd991b6bbce30d10b88f464140338f706c5b (patch)
tree5f3215ba22d5630df1345f5cb5692155a8ac6e6e /sc/source/core/tool/interpr3.cxx
parent82275ecb0c5aae406dcf6637a56a84d729e78ac7 (diff)
fdo#70000 add support for COVARIANCE.P and COVARIANCE.S functions
These functions have been introduced with Excel 2010, but were not supported yet in calc. COVARIANCE.P (population) replaces the COVAR function, but the COVAR function remains present (in Excel as well as in calc). COVARIANCE.S (sample) is a new function. Change-Id: If5501b4090fb716adfb3d121c7898528fd1b7ad4 Reviewed-on: https://gerrit.libreoffice.org/6135 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/core/tool/interpr3.cxx')
-rw-r--r--sc/source/core/tool/interpr3.cxx21
1 files changed, 15 insertions, 6 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 36f7fc1f38d9..ee30c4869b9d 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3790,16 +3790,22 @@ void ScInterpreter::ScCorrel()
ScPearson();
}
-void ScInterpreter::ScCovar()
+void ScInterpreter::ScCovarianceP()
{
- CalculatePearsonCovar(false,false);
+ CalculatePearsonCovar( false, false, false );
+}
+
+void ScInterpreter::ScCovarianceS()
+{
+ CalculatePearsonCovar( false, false, true );
}
void ScInterpreter::ScPearson()
{
- CalculatePearsonCovar(true,false);
+ CalculatePearsonCovar( true, false, false );
}
-void ScInterpreter::CalculatePearsonCovar(bool _bPearson,bool _bStexy)
+
+void ScInterpreter::CalculatePearsonCovar( bool _bPearson, bool _bStexy, bool _bSample )
{
if ( !MustHaveParamCount( GetByte(), 2 ) )
return;
@@ -3879,7 +3885,10 @@ void ScInterpreter::CalculatePearsonCovar(bool _bPearson,bool _bStexy)
} // if ( _bPearson )
else
{
- PushDouble( fSumDeltaXDeltaY / fCount);
+ if ( _bSample )
+ PushDouble( fSumDeltaXDeltaY / ( fCount - 1 ) );
+ else
+ PushDouble( fSumDeltaXDeltaY / fCount);
}
}
}
@@ -3907,7 +3916,7 @@ void ScInterpreter::ScRSQ()
void ScInterpreter::ScSTEXY()
{
- CalculatePearsonCovar(true,true);
+ CalculatePearsonCovar( true, true, false );
}
void ScInterpreter::CalculateSlopeIntercept(bool bSlope)
{