[Libreoffice-commits] core.git: chart2/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Mon Mar 3 09:15:28 PST 2014
chart2/source/tools/PolynomialRegressionCurveCalculator.cxx | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
New commits:
commit 00cb825ab3f16a94f1e8311ba0c24f72588e788e
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date: Sat Mar 1 00:20:53 2014 +0100
fdo#75538 R^2 calculation for trendline similar to LINEST function
Modify for forced intercept of trendline, calculation of R^2 in the same
way as LINEST function does calculation
Change-Id: Ic943b1ca1bbe30b1a4b88e2a338eb9dc34d848b6
Reviewed-on: https://gerrit.libreoffice.org/8402
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 90be5a1..9b39e01 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