Kaydet (Commit) 00cb825a authored tarafından Laurent Balland-Poirier's avatar Laurent Balland-Poirier Kaydeden (comit) Tomaž Vajngerl

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/8402Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 6a71b8d9
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment