Author |
Topic  |
|
ylibp
USA
Posts |
Posted - 01/24/2005 : 1:13:21 PM
|
Origin 7.0 These are Data
col(X) col(B) Col(B1) col(C) 0 0.45968 0.45968 0.45968 0.03067 0.45575 0.45575 0.45575 0.05205 0.45254 0.45254 0.45254 0.1 0.44414 0.44414 0.44414 0.17067 0.42936 0.42936 0.42936 0.34311 0.38642 0.38642 0.38641 0.58933 0.32282 0.32282 0.32281 1 0.24072 0.24072 0.24071 1.50133 0.18831 0.18831 0.18824 2.176 0.15892 0.15892 0.15916 2.62578 0.14516 0.14516 0.14989 3.26133 0.12791 0.12791 0.18088 3.89067 0.11652 0.11652 0.43333 4.42933 0.11048 0.11048 1.23579 5.13867 0.10211 0.10211 4.76895 5.992 0.09002 0.09002 19.96049 7.016 0.08361 0.08361 86.63033 7.784 0.07652 0.07652 226.60682 8.86133 0.06993 0.06993 748.46242 10 0.0638 0.0638 2270.84758
We fit our data (in col B) by using y=p1+p2*x+p3*x^2+p4*x^3+p5*x^4+p6*x^5+p7*x^6+p8*x^7+p9*x^8+p10*x^9+p11*x^10
We get a fiting data (in col B1) and a series parameters in the equation P1 0.45968 P2 -0.11441 P3 -0.47128 P4 0.65416 P5 -0.40281 P6 0.14274 P7 -0.03135 P8 0.00433 P9 -0.00037 P10 0.00002 P11 -3.5314E-7
Then we use this equation to calculate the fitting data again, y=0.45968-0.11441*col(x)-0.47128*col(x)^2+0.65416*col(x)^3-0.40281*col(x)^4+0.14274*col(x)^5-0.03135*col(x)^6+0.00433*col(x)^7-0.00037*col(x)^8+0.00002*col(x)^9-3.5314E-7*col(x)^10
The calculated data are in col C.
We find the fitting values in col B are very different from calculated data in col C.
What is the problem? Origin does not very well for fitting? |
|
easwar
USA
1965 Posts |
Posted - 01/24/2005 : 1:25:25 PM
|
Hi ylibp,
When you fit with many terms with such high order as x^10, even a small difference in the coefficient value can make a big difference in the computed value.
When the fit results are reported to the result log or pasted to the graph, they are reported with some preset precision. So if you just use the values reported or pasted on the graph, there may be some loss in precision that is leading to a large difference.
It looks like you are using the NLSF tool and defining a new function with the many high order terms that you are using. When the fit is done, if you wish to generate a new column using a formula, instead of just pasting the reported values into the formula for your coefficients, use the internal values stored in the NLSF object, such as:
y=nlsf.p1 + nlsf.p2 * col(x) + nlsf.p3 * col(x)^2 ....
If what you are trying to acheive is to generate the fit line data for a specific set of x values, you can use the Uniform X option in the NLSF tool under the Scripts->After Fit menu of the NLSF tool where you can specify the number of x values. For more flexibility, you can programmatically access the NLSF object either from LabTalk or from Origin C. Post in the programming forums if you need help with that.
Easwar OriginLab
|
 |
|
easwar
USA
1965 Posts |
Posted - 01/24/2005 : 1:56:20 PM
|
Hi ylibp,
I also wanted to point out the following. When you fit your data with such an equation, you will see that on the Fit page of the NLSF tool, there is a Dependency column with values reported for each parameter. You will notice that for your data and your equation, all dependencies beyond P1 and P2 are set to 1. This means that there are strong dependencies between many of the parameters - in other words the parameters are not unique, or the function is very heavily overparametrized.
You may want to take a look at this article about nonlinear fitting: http://www.tipmagazine.com/tip/INPHFA/vol-9/iss-2/p24.html
Easwar OriginLab
|
 |
|
ylibp
USA
Posts |
Posted - 01/24/2005 : 4:46:59 PM
|
quote:
Hi ylibp,
When you fit with many terms with such high order as x^10, even a small difference in the coefficient value can make a big difference in the computed value.
When the fit results are reported to the result log or pasted to the graph, they are reported with some preset precision. So if you just use the values reported or pasted on the graph, there may be some loss in precision that is leading to a large difference.
It looks like you are using the NLSF tool and defining a new function with the many high order terms that you are using. When the fit is done, if you wish to generate a new column using a formula, instead of just pasting the reported values into the formula for your coefficients, use the internal values stored in the NLSF object, such as:
y=nlsf.p1 + nlsf.p2 * col(x) + nlsf.p3 * col(x)^2 ....
If what you are trying to acheive is to generate the fit line data for a specific set of x values, you can use the Uniform X option in the NLSF tool under the Scripts->After Fit menu of the NLSF tool where you can specify the number of x values. For more flexibility, you can programmatically access the NLSF object either from LabTalk or from Origin C. Post in the programming forums if you need help with that.
Easwar OriginLab
Dear Easwar
Thank you for your two emails. They are very helpful. I try to use y=nlsf.p1 + nlsf.p2 * col(x) + nlsf.p3 * col(x)^2 .... It works very well. The data got from the equation is very colse to my original data. However, I cannot get the exact parameters P1, P2, ... and P11. The purpose I fit these data is to hope to get an expression y=f(x) within 0<x<10 no matter what the parameters (p1, ... p11) are big or small, dependent or independent. According to this expression y=f(x), I want to do other calculations such as Y=f(x)/f(x/3). Could you give me a suggestion? How can I get an exact y=f(x) by fitting the experimental data by use of Origin. Thank you.
Yang |
 |
|
greg
USA
1379 Posts |
Posted - 01/31/2005 : 11:06:42 AM
|
You can get more resolution for the coefficients, but you really need to understand Easwar's point about high order polynomials. A minor change in the least significant value of a high order coefficient can produce a huge change in the output. As the order approaches the number of datapoints, the exercise approaches meaninglessness (unless you goal is to demonstrate the Binomial Theorem).
How to get more resolution depends upon how you are doing the Polynomial fit. If you used the Advanced Fitter, then Options : Control will let you increase parameter significant digits as reported to Results Log. You can also directly control display in the Script Window as in: type P9 \x3D $(P9,%38.35f);
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 01/31/2005 : 12:39:10 PM
|
quote: As the order approaches the number of datapoints, the exercise approaches meaninglessness (unless you goal is to demonstrate the Binomial Theorem).
Easwar's observations about the dependancies suggest that all terms beyond the linear are indeed meaningless in this case. If the goal is merely to find Y = f(x)/f(x/3) from the data it would probably be sufficient to represent their data as a spline or B spline curve.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/31/2005 1:08:32 PM
Edited by - Mike Buess on 01/31/2005 1:09:34 PM |
 |
|
easwar
USA
1965 Posts |
Posted - 01/31/2005 : 1:05:53 PM
|
quote:
If the goal is merely to find Y = f(x)/f(x/3) from the data it would probably be sufficient to represent their data as a spline or B spline curve.
Hi Mike,
Thanks for pointing this out. The user contacted tech support directly and this is what we suggested.
For the benefit of others who may read this thread, here are steps on how to generate a new dataset based on a spline connection of existing raw data: 1> make a line+symbol plot of your raw data 2> bring up Plot Details, and then click on the Line tab on the right 3> change the Connection drop-down from Straight to Spline or B-Spline and click OK to close dialog 4> The line in the line+symbol plot should now be Spline/B-Spline 5> Bring up the Analysis->Interpolate/Extrapolate tool 6> Specify desired X start, end points and number of points, and click Apply/OK to generate a new data curve based on the new line connection type. The newly generated data will be in a hidden worksheet that you can bring up to do further processing as needed.
Once the line connection has been set, one can also go to the script window and type commands such as: data1_b(1.5)= where 1.5 is the new x value for which the corresponding y value is desired. By default this would be computed using linear interpolation. But if the line type is changed to spline or b-spline, then the value is computed using spline/b-spline parameters. (It is assumed here that the Y data of the curve is located in col B of data1 worksheet.)
Also, the key difference between spline and b-spline connection types is that a spline connection will result in a line that goes thru each and every data point, whereas a b-spline connection typically does not.
Easwar OriginLab
|
 |
|
EastWestTrav
Azerbaijan
Posts |
Posted - 01/26/2007 : 1:47:58 PM
|
Hello,
I just had the same problem fitting polynomials of higher order. I increased precision by setting the number of significant digits to 16 (more didn't work). Is that because of the data type of the coefficient array (it is double)? Would I get more significant digits setting it to long double?
|
 |
|
zachary_origin
China
Posts |
Posted - 01/28/2007 : 9:30:36 PM
|
As Easwar has pointed out that "When you fit with many terms with such high order as x^10, even a small difference in the coefficient value can make a big difference in the computed value." There is no use of simply increasing the significant digits to get a better fitting. And I think aslo no other software can fit a polynomial equation with high orders, say higher than 6.
Zachary OriginLab Technical Services.

Edited by - zachary_origin on 01/28/2007 9:34:12 PM |
 |
|
EastWestTrav
Azerbaijan
Posts |
Posted - 01/30/2007 : 03:20:01 AM
|
quote:
As Easwar has pointed out that "When you fit with many terms with such high order as x^10, even a small difference in the coefficient value can make a big difference in the computed value." There is no use of simply increasing the significant digits to get a better fitting. And I think aslo no other software can fit a polynomial equation with high orders, say higher than 6.
Zachary OriginLab Technical Services.
Well, I understood that even a small difference in the coefficient value can make a big difference in the end.
Maybe I should explain what I want to do with the polynomial. I fitted an transmission spectrum of a attenuation filter in a defined range (from 670 nm to 1000 nm). I want to place the coefficients into an Origin C function that I can use this function in any Origin project in any column. The function can be placed in the user folder. That would be a fast possibility to correct any collected spectrum with any combination of used filters in the gived spectrum range.
The solution suggested by easwar needs the interpolated data sheet to be present in the project, doesn't it? |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 01/30/2007 : 09:40:28 AM
|
quote: The solution suggested by easwar needs the interpolated data sheet to be present in the project, doesn't it?
Yes. Save the worksheet containing the interpolated data to a worksheet file using File > Save Window As and append to any project with File > Append.
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|