Issue 112773 - Exponential fit is broken for small values
Summary: Exponential fit is broken for small values
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: chart (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: kla
QA Contact: issues@graphics
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-28 21:15 UTC by jacobfe
Modified: 2017-05-20 11:41 UTC (History)
4 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
example document showing the problem (20.55 KB, application/vnd.oasis.opendocument.spreadsheet)
2010-11-15 16:39 UTC, IngridvdM
no flags Details
Changed output for cases with underflow. Because my problems with charts (see PM) an intensely testing is currently not possible. Please comment, whether the equation is in the desired format, otherwise I will change it. (1.94 KB, application/x-compressed)
2010-11-15 23:36 UTC, Regina Henschel
no flags Details
Testcases. Do not forget to update the charts. (73.54 KB, application/vnd.oasis.opendocument.spreadsheet)
2010-11-20 17:41 UTC, Regina Henschel
no flags Details
Patch for trendline itself and for equation (5.73 KB, text/plain)
2010-11-20 18:13 UTC, Regina Henschel
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description jacobfe 2010-06-28 21:15:22 UTC
Description:	Ubuntu 10.04 LTS
Release:	10.04

openoffice.org-calc:1:3.2.0-7ubuntu4.1 0

The exponential fit is broken.  Using the following data plot
A                      B
0.000568         0.22
0.001136         0.05
0.00170           0.02
0.000136         0.97
0.000329         0.42

Plot and add a trend-line.  Make the trend-line exponential and you get a
garbage fit.  If you multiply column A by 4, the fit works.  Multiply by 3 and
it fails.  It appears that the algorithm used for this type of trend-line is
flawed and has limitations that do not occur in MS Excel.
Comment 1 Regina Henschel 2010-09-18 12:07:01 UTC
An "exponentiell trend" means that you want to use a model y = a * b^x. Using
your data the basis b would be exp(-2440). That is so near to zero, that it
underflows to zero using double precision.

The trend line calculation should not use a and b to calculate the y-values, but
use ln(a) and ln(b) and first calculate ln(y), same as it is done in
ScInterpreter::CalculateTrendGrowth().

As workaround you can calculate intermediate value pairs using GROWTH and add
them as additional data series to your chart. 
Comment 2 Regina Henschel 2010-09-18 12:16:34 UTC
Change component to Chart.
Comment 3 IngridvdM 2010-11-15 16:39:30 UTC
Created attachment 74879 [details]
example document showing the problem
Comment 4 IngridvdM 2010-11-15 16:42:19 UTC
taking issue
Comment 5 Regina Henschel 2010-11-15 23:36:07 UTC
Created attachment 75014 [details]
Changed output for cases with underflow. Because my problems with charts (see PM) an intensely testing is currently not possible. Please comment, whether the equation is in the desired format, otherwise I will change it.
Comment 6 IngridvdM 2010-11-18 18:22:24 UTC
Thanks Regina! The patch looks very good already :-) . I think it would be cool
to have the equation always in the new format. That would better fit to the ODF
spec anyhow. In addition I would skip the multiplier point as it is so longish.
Comment 7 Regina Henschel 2010-11-20 17:41:16 UTC
Created attachment 75073 [details]
Testcases. Do not forget to update the charts.
Comment 8 Regina Henschel 2010-11-20 18:13:14 UTC
Created attachment 75074 [details]
Patch for trendline itself and for equation
Comment 9 Regina Henschel 2010-11-20 18:47:53 UTC
I have changed the equation in a way that for all normal cases it has the form
"f(x)=Intercept exp(logSlope x)".

If Intercept is near 1 but Slope is not near 1, I use "f(x)=exp(logSlope x)"
instead of "f(x)= 1 exp(logSlope x)". If both Intercept and Slope are near 1, I
use the form "f(x)=exp(logIntercept + logSlope x)".

If Intercept is near 0, I use "f(x)=exp(logIntercept + logSlope x)" otherwise
the output would be "f(x)=0 exp(logSlope x)" which is not informative for the user.

If all y-Values are not positive the equation has the NaN error message inside
the string. But in those cases a trend line is not drawn at all, so the user
should already notice that there is an error. 
Comment 10 IngridvdM 2010-11-23 17:28:27 UTC
The new patch looks very good. Thanks a lot Regina! :-)
I've created CWS chart51 and applied it there.
Comment 11 IngridvdM 2011-02-17 18:08:13 UTC
Thomas, please verify in CWS chart51.
Comment 12 kla 2011-03-07 10:39:30 UTC
See ok in cws -> verified