[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - chart2/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Fri Mar 7 04:46:52 PST 2014
chart2/source/tools/PolynomialRegressionCurveCalculator.cxx | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
New commits:
commit cade56eef6d23aa7dd6e374858cf30ff3fcd163b
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date: Wed Mar 5 10:43:54 2014 +0100
fdo#75538 R^2 calculation of trendline similar to LINEST function
Modify for forced intercept of trendline, calculation of R^2 in the same
way as LINEST function does calculation
Update fo 4.2
Change-Id: I06ba4e7f5e07f7db150e1bf1070870bf64ad6f61
Reviewed-on: https://gerrit.libreoffice.org/8462
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index 21b564d..3c15d28 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -168,7 +168,6 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
double aSumError = 0.0;
double aSumTotal = 0.0;
double aSumYpred2 = 0.0;
- double aSumYactual2 = 0.0;
for( sal_Int32 i = 0; i < aNoValues; i++ )
{
@@ -177,15 +176,14 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
double yPredicted = getCurveValue( xValue );
aSumTotal += (yActual - yAverage) * (yActual - yAverage);
aSumError += (yActual - yPredicted) * (yActual - yPredicted);
- aSumYpred2 += yPredicted * yPredicted;
- aSumYactual2 += yActual * yActual;
+ if(mForceIntercept)
+ aSumYpred2 += (yPredicted - mInterceptValue) * (yPredicted - mInterceptValue);
}
double aRSquared = 0.0;
if(mForceIntercept)
{
- if(aSumYactual2 != 0.0)
- aRSquared = aSumYpred2 / aSumYactual2;
+ aRSquared = aSumYpred2 / (aSumError + aSumYpred2);
}
else
{
More information about the Libreoffice-commits
mailing list