summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Jung <phil.jung@free.fr>2015-06-21 22:09:07 +0000
committerPhilippe Jung <phil.jung@free.fr>2015-06-21 22:22:39 +0000
commitd16e154c627ecc0cb21aaf4b28f7f5ae48ebbde1 (patch)
treedf163559a0db5ec63d53c5fa05932e3df97147de
parent9ed033917b0bdaeb663395224a5e5b8b20a67169 (diff)
Revert "tdf#92231 Potential regression curve calculation is wrong"
This reverts commit e0e285574244e855fd148ab7320b1aeb5914655a. Wrong fix Change-Id: Iddcbb84efbfc88013c6f2a217cb44061016c043b Reviewed-on: https://gerrit.libreoffice.org/16405 Reviewed-by: Philippe Jung <phil.jung@free.fr> Tested-by: Philippe Jung <phil.jung@free.fr>
-rw-r--r--chart2/source/tools/PotentialRegressionCurveCalculator.cxx15
1 files changed, 3 insertions, 12 deletions
diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
index 6f3d438ced6f..7495c912b6ea 100644
--- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
@@ -51,14 +51,6 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
aXValues, aYValues,
RegressionCalculationHelper::isValidAndBothPositive()));
- // We try to get y =C * D^x
- // switching to neperian logs:
- // ln(y) = ln(C) + x ln(D)
- // So we make a linear regression and get
- // slope = ln(D) => D = exp(slope)
- // intercept = ln(C) => C = exp(intercept)
- // Warning: the linear regression is between
- // ln(y) and x. Not between ln(y) and ln(x)
const size_t nMax = aValues.first.size();
if( nMax == 0 )
{
@@ -72,7 +64,7 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
size_t i = 0;
for( i = 0; i < nMax; ++i )
{
- fAverageX += aValues.first[i] ;
+ fAverageX += log( aValues.first[i] );
fAverageY += log( aValues.second[i] );
}
@@ -83,7 +75,7 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
double fQx = 0.0, fQy = 0.0, fQxy = 0.0;
for( i = 0; i < nMax; ++i )
{
- double fDeltaX = aValues.first[i] - fAverageX;
+ double fDeltaX = log( aValues.first[i] ) - fAverageX;
double fDeltaY = log( aValues.second[i] ) - fAverageY;
fQx += fDeltaX * fDeltaX;
@@ -95,7 +87,6 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression(
m_fIntercept = fAverageY - m_fSlope * fAverageX;
m_fCorrelationCoeffitient = fQxy / sqrt( fQx * fQy );
- m_fSlope = exp( m_fSlope );
m_fIntercept = exp( m_fIntercept );
}
@@ -109,7 +100,7 @@ double SAL_CALL PotentialRegressionCurveCalculator::getCurveValue( double x )
if( ! ( ::rtl::math::isNan( m_fSlope ) ||
::rtl::math::isNan( m_fIntercept )))
{
- fResult = m_fIntercept * pow( m_fSlope, x );
+ fResult = m_fIntercept * pow( x, m_fSlope );
}
return fResult;