Author |
Topic |
|
fini
Germany
Posts |
Posted - 08/28/2007 : 7:22:15 PM
|
I created an own function with 1 free parameter to fit my data. The problem is the created curve doesnt fit, but it should.
function with paramater delta: y=(1+delta*cos(x*2*(3,141592654)/360))/(1-delta*cos(x*2*(3,141592654)/360))
data: x y Fehler y
270 1,023 0,080 300 0,916 0,072 330 0,930 0,077 0 0,922 0,080 30 0,837 0,070 60 0,888 0,073 90 0,742 0,057 120 0,724 0,060 150 0,832 0,068 180 0,977 0,079 210 1,112 0,093 240 1,092 0,087
I used different start values for delta, but it never fits. The created curves doesnt seem to base on the datas...I really could need some help.
|
|
Mike Buess
USA
3037 Posts |
Posted - 08/28/2007 : 9:25:18 PM
|
The function does not describe your data very well. For one thing, the function is always symmetric about x=180 degrees whereas your data are not.
Mike Buess Origin WebRing Member |
|
|
fini
Germany
Posts |
Posted - 08/29/2007 : 09:35:21 AM
|
youre right date has to be symmetric left and right from 180 degree
but in general: how did u get that curve? if i take the same value you have as startvalue the program gives me somethinng complete different. i think it does only some iterations...if i simulate with the same value the curve is different too...what am i doing wrong?
Edited by - fini on 08/29/2007 09:47:51 AM |
|
|
Mike Buess
USA
3037 Posts |
Posted - 08/29/2007 : 10:21:17 AM
|
The solid red curve was created by the fitter. To avoid writing out the equation again I created the red scatter plot with nlsf.funcval(). After performing the fit, create column D and run the following script from the script window...
for(i=1;i<=wks.maxrows;i++) { col(D)[i]=nlsf.funcval(col(A)[i]); };
The simulated curve matches the fit curve exactly. If you used Origin C for the fit function and rewrote the function to simulate the fit in LabTalk the differences you see might be caused by the fact that the Origin C cos() function always assumes the argument is in radians whereas the LabTalk cos() function uses the angular unit selection in Tools> Options.
...As for the fitting session itself I'm not sure what you are doing wrong. If I start out with delta = -0.0167 then delta stays the same after 1 or 100 iterations.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/29/2007 10:32:50 AM |
|
|
larry_lan
China
Posts |
Posted - 08/29/2007 : 12:28:13 PM
|
I think maybe you can use some other model to fit the data? Original data is periodic but the model is not, it is actually a hyperbola function.
Since your X range is [0, 360], so the range of cos(x*2*(3,141592654)/360) is [-1, 1]. Let F = delta*cos(x*2*(3,141592654)/360), we can change the function to:
y = (1+F)/(1-F), where F = [-delta, delta].
which is a typical hyperbola curve looks like:
Larry OriginLab Technical Services
Edited by - larry_lan on 08/29/2007 12:30:50 PM |
|
|
fini
Germany
Posts |
Posted - 09/07/2007 : 08:31:03 AM
|
Thx for the help. I did a calculating misstake. Thats why the old date is asymmetric for and after 180 degree. Now the data is symmetric. I think i fugured out what is wrong: Just to see how the program use cosinus i simulated y=delta*cos(x), with x=[0...360]. what i got and still get is not a cosinus function. After that i tried y=delta*cos(x*2*(3,14)/360), delta=1. That was even worse.
What is wrong? Does cos stand for cosinus function when you define your own fitfunction? |
|
|
Mike Buess
USA
3037 Posts |
Posted - 09/07/2007 : 10:07:59 AM
|
LabTalk's cosine function is cos(x) and uses the angular unit chosen in options (Tools> Options, Numeric tab). Choices are radian, degree or gradian. If neither of the expressions you quoted give the correct result then yours must be set to gradian.
Origin C's cosine function is also cos(x) but the angular unit is always radian.
Both LabTalk and Origin C have a global constant called PI so there is no need to write out the value. I.e., if angular unit is radian you can use cos(x*pi/180).
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 09/07/2007 10:19:06 AM |
|
|
|
Topic |
|
|
|