Bug 224225 - 'fit linear weighted' plugin produces different results
Summary: 'fit linear weighted' plugin produces different results
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: freebody.kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-25 20:58 UTC by freebody.kst
Modified: 2010-01-26 19:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description freebody.kst 2010-01-25 20:58:34 UTC
Version:           1.9.0_devel (using Devel)
OS:                Linux
Installed from:    Compiled sources

PROBLEM:
I tried to plot and fit the same data file using gnuplot and kst, the fit results are different.
 
STEPS TO REPRODUCE:
1. create a txt file containing the following data


2  3.5  0.55
4  7.2  0.65
6  9.5  0.74
8  17.1  0.5
10  20.0  0.85
12  25.5  0.6

this is an example from the following web page
http://phobos.physics.uiowa.edu/~rlm/mathcad/linear%20fitting%20example%20with%20outlier.htm

2. construct a curve in kst
1.Data --> New Curve...
Choose X from the drop-down list for the X axis vector
Choose Y from the drop-down list for the Y axis vector
Choose DelY from the drop-down list for the +Y error bar
Check Show points in the Appearance panel
Click OK to view the curve

3. curve fitting in kst
Click anywhere on the plot 
Choose Fit --> Y in the appearing context menu
Choose Fit linear weighted(v0.1) in the drop down list of Plugin Selection
Click OK 

4. fit in gnuplot
f(x)=a*x+b
a=1
b=1
fit f(x) 'fit.dat' using 1:2:3 via a,b
 
RESULTS:
in kst, gradient:2.2310; intercept:-1.9601
 
EXPECTED RESULTS:
according to the webpage, the result of the weighted linear fit is gradient:2.23; intercept:-1.528. gnuplot confirms the same result.
Comment 1 Andrew Walker 2010-01-25 23:37:26 UTC
For all weighted fits the expected input are x, y, and weight. Typically the weight is 1/yError^2.

When using a weighted-fit-plugin directly it should be apparent to the user that a weight (as opposed to error) is required.

However, this is not the case when fitting by right-clicking on a curve (with y-errors already specified) and selecting a weighted fit. In that case the weights field is automatically set to the yError values and also disabled.
Comment 2 Andrew Walker 2010-01-26 01:55:51 UTC
SVN commit 1080293 by arwalker:

CCBUG:224225 remove automatic assignment of weight vector in interactive non-linear fit from curve

 M  +5 -8      kstfitdialog_i.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1080293
Comment 3 Andrew Walker 2010-01-26 01:57:50 UTC
To avoid potential confusion on the part of the user the documentation should be modified to stress that the weight is not the same as the error. Typically the weight is given as 1/yError^2.
Comment 4 freebody.kst 2010-01-26 19:14:41 UTC
The docbook and website have been updated.